Woozypictures
New Member
- Joined
- Aug 19, 2022
- Messages
- 4
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
- Mobile
- Web
Hi All,
I've been using this fantastic forum for previous VBA issues I've had, seeing other peoples posts and using the brilliant answers people have provided, however It seems Im going to need the extra help on this one!
I have a workbook that I use as a report for Aged Debtors, with a query that pulls data from our ERP system on a daily basis. The idea is that this VBA code is activated by a button on a sheet called "DATA". Once clicked it scans the query worksheet "Debtors", and if any cells in column P are blank, to copy columns (B,C,E) from this sheet into another sheet called "IGNORE"'. Issue is the code I've written pulls the whole row, not the specific columns. This is the code I have currently:
--------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()
A = Worksheets("Debtors").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To A
If Worksheets("Debtors").Cells(i, 16).Value = "" Then
Worksheets("Debtors").Rows(i).Copy
Worksheets("IGNORE").Activate
B = Worksheets("IGNORE").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("IGNORE").Cells(B + 1, 1).Select
ActiveSheet.Paste
Worksheets("Debtors").Activate
End If
Next
Application.CutCopyMode = False
End Sub
--------------------------------------------------------------------------------------
So just to clarify:
I've been using this fantastic forum for previous VBA issues I've had, seeing other peoples posts and using the brilliant answers people have provided, however It seems Im going to need the extra help on this one!
I have a workbook that I use as a report for Aged Debtors, with a query that pulls data from our ERP system on a daily basis. The idea is that this VBA code is activated by a button on a sheet called "DATA". Once clicked it scans the query worksheet "Debtors", and if any cells in column P are blank, to copy columns (B,C,E) from this sheet into another sheet called "IGNORE"'. Issue is the code I've written pulls the whole row, not the specific columns. This is the code I have currently:
--------------------------------------------------------------------------------------
Private Sub CommandButton1_Click()
A = Worksheets("Debtors").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To A
If Worksheets("Debtors").Cells(i, 16).Value = "" Then
Worksheets("Debtors").Rows(i).Copy
Worksheets("IGNORE").Activate
B = Worksheets("IGNORE").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("IGNORE").Cells(B + 1, 1).Select
ActiveSheet.Paste
Worksheets("Debtors").Activate
End If
Next
Application.CutCopyMode = False
End Sub
--------------------------------------------------------------------------------------
So just to clarify:
- I have a button on a worksheet called "DATA".
- When you click it, the macro scans a worksheet called "Debtors" column P, and anything blank it picks up the whole row and copy/pastes it to a worksheet called "IGNORE".
- I need it to copy paste specific columns (B,C and E) to the worksheet "IGNORE" whilst keeping the rest of the rules set (i.e next blank cell etc, dont delete dont overwrite)