Hello,
Hope you are well.
I have a loop that should place data from Sheet18 to Sheet11 from a Userform showing on Sheet1:
If a Column 2 value on Sheet18 is equal to a textbox value similar to FDS002/18 AND
a Column 6 value on Sheet18 is equal to a combobox value eg SF AND
a Column 10 value on Sheet18 equals a value in a combobox eg WP.
But for some reason which I cannot figure out in the last 15 hours, it does not run. I have tried placing the If values on the spreadsheet and run the logical If from a module with f8, but the loop runs as if the above values does not exist on Sheet18, but they do. At best it only places one line on Sheet11.
I removed the logic and ran the loop and only one line was placed on Sheet11 (not the same as above). I also replaced the forward slash with an underscore in the first logical If question; reversed the logic by asking whether the textboxes and comboboxes is equal to Sheet18 values; tried differing methods of referencing ranges and I rewrote the code using the Application.Match function, but again no joy.
Can someone please point me in the right direction or give advice?
My code as is now:
Regards
Hope you are well.
I have a loop that should place data from Sheet18 to Sheet11 from a Userform showing on Sheet1:
If a Column 2 value on Sheet18 is equal to a textbox value similar to FDS002/18 AND
a Column 6 value on Sheet18 is equal to a combobox value eg SF AND
a Column 10 value on Sheet18 equals a value in a combobox eg WP.
But for some reason which I cannot figure out in the last 15 hours, it does not run. I have tried placing the If values on the spreadsheet and run the logical If from a module with f8, but the loop runs as if the above values does not exist on Sheet18, but they do. At best it only places one line on Sheet11.
I removed the logic and ran the loop and only one line was placed on Sheet11 (not the same as above). I also replaced the forward slash with an underscore in the first logical If question; reversed the logic by asking whether the textboxes and comboboxes is equal to Sheet18 values; tried differing methods of referencing ranges and I rewrote the code using the Application.Match function, but again no joy.
Can someone please point me in the right direction or give advice?
My code as is now:
Code:
Dim lastCel As Long, x As Long
Dim openRow As Long
Application.ScreenUpdating = False
With Sheet18
openRow = Sheet11.Range("A" & Rows.Count).End(xlUp).row
lastCel = .Range("B" & Rows.Count).End(xlUp).row
For x = 2 To lastCel
If .Cells(x, 2).Value = txbVragVerwysing.Text And .Cells(x, 6) _
.Value = cbSundrVerdPlaas.Value And .Cells(x, 10).Value = cbSundrVerdDroog.Value Then
Sheet11.Range("A" & openRow).Value = .Cells(x, 6).Value
Sheet11.Range("A" & openRow).Offset(0, 2).Value = .Cells(x, 7).Value
Sheet11.Range("A" & openRow).Offset(0, 3).Value = .Cells(x, 10).Value
Sheet11.Range("A" & openRow).Offset(0, 4).Value = .Cells(x, 9).Value
Sheet11.Range("A" & openRow).Offset(0, 5).Value = .Cells(x, 21).Value
End If
Next x
End With
Application.ScreenUpdating = True
Regards
Last edited: