VBA code in my command button doesn't work
Solved/Closed
ips999
-
Updated on Jun 15, 2017 at 05:06 PM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - May 28, 2017 at 08:06 PM
vcoolio Posts 1404 Registration date Thursday July 24, 2014 Status Moderator Last seen September 15, 2023 - May 28, 2017 at 08:06 PM
Related:
- VBA code in my command button doesn't work
- Huawei test code - Guide
- Samsung keypad reset code - Guide
- Csgo speed command - Guide
- Number to words in excel without vba - Guide
- Whatsapp verification code online - Guide
1 response
vcoolio
Posts
1404
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
September 15, 2023
259
May 28, 2017 at 08:06 PM
May 28, 2017 at 08:06 PM
Hello Ips999,
Try the following code, assigned to the button:-
If the Status column is Column G, then the above code will filter that column for the criteria "Reorder" and then transfer the relevant row of data (just from Columns A - E) to sheet2.
If you wish to clear the "used" data from sheet1 that has been transferred to sheet2, then just remove the apostrophe(') from the begining of line 14 in the code above (the line in green font).
I hope that this helps.
Cheerio,
vcoolio.
Try the following code, assigned to the button:-
Sub TransferData() Dim lr As Long Application.ScreenUpdating = False Sheet1.Range("G1", Sheet1.Range("G" & Sheet1.Rows.Count).End(xlUp)).AutoFilter 1, "Reorder", 7 lr = Sheet1.Range("A" & Rows.Count).End(xlUp).Row If lr > 1 Then Sheet1.Range("A2", Sheet1.Range("E" & Sheet1.Rows.Count).End(xlUp)).Copy Sheet2.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues 'Sheet1.Range("A2", Sheet1.Range("A" & Sheet1.Rows.Count).End(xlUp)).EntireRow.Delete Sheet2.Columns.AutoFit End If Sheet1.[G1].AutoFilter Application.CutCopyMode = False Application.ScreenUpdating = True End Sub
If the Status column is Column G, then the above code will filter that column for the criteria "Reorder" and then transfer the relevant row of data (just from Columns A - E) to sheet2.
If you wish to clear the "used" data from sheet1 that has been transferred to sheet2, then just remove the apostrophe(') from the begining of line 14 in the code above (the line in green font).
I hope that this helps.
Cheerio,
vcoolio.