I have a workbook with laboratory data.
An input page has two columns one for Influent values and one for Effluent values.
The Influent starts with B13 to lRow and Effluent starts with C13 to lRow.
The input page has a combobox called cbSheet so the user can select which facility log sheet to transfer this data to.
I have written a macro that should copy and transpose Influent data from the Input sheet to the sheet selected in the combobox and paste it after the last used row.
Next the macro should copy the Effluent data and paste it directly below the Influent data on the same sheet.
I would like the macro to alternate copying influent transposing and pasting to the sheet selected in the combobox followed by the effluent.
There should be something like this on the log sheet:
Influent "DATA"
Effluent "DATA"
Influent "DATA"
Effluent "DATA"
I get an error trying to reference the cbSheet combobox.
Variable Not Defined
Also, I only have the influent data selected.
How do I include the effluent so they alternate as new data is added every week?
Dim wb As Workbook
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lRow1 As Long
Dim lRow2 As Long
Dim lRow3 As Long
Set wb = ThisWorkbook
Set ws1 = wb.Sheets(1)
lRow1 = ws1.Cells(Rows.Count, 2).End(xlUp).Row
lRow2 = ws1.Cells(Rows.Count, 3).End(xlUp).Row
If ws1.Range("A8").Value <> "" Then
Set ws2 = wb.Worksheets(cbSheet.Value)
lRow3 = ws2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws1
.Range("A13" & lRow1).Copy
ws2.Range("A15" & lRow2).PasteSpecial xlPasteValues, Transpose:=True
End With
End If
End Sub