Loop Thru Columns and copy/paste until blank - please help

ExcelTrick

New Member
Joined
Dec 4, 2018
Messages
2
Hello,

I am tying to create a macro/VBA code that would loop thru a column, find value, then copy everything below until the next blank cell and paste to a different sheet and start with the next column to do the same thing until next column is empty.

something like this:

Loop thru Col A
Find "123*"
Copy All below A1 until blank
Create Sheet "Destination"
Paste in Col E next blank Cell col E

Next CoL B and so on Until next Col is blank

Thank you in advance for all your help
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
try these codes
Code:
Sub trick()
Dim LR As Long, LC As Long, a As Long, d As Long
Dim b As String
LC = Cells(1, Columns.Count).End(xlToLeft).Column
c = InputBox("enter search term")
    For a = 1 To LC
    b = Chr(a + 64)
    LR = Cells(Rows.Count, b).End(xlUp).Row
    d = WorksheetFunction.Match(c, Range(b & "1:" & b & LR), 0)
    Range(b & d & ":" & b & LR).Copy
    Sheets("sheet2").Range(b & "1").PasteSpecial
    Next a
MsgBox "complete"
End Sub
ravishankar
 
Upvote 0
Thank you for your reply Ravishakar. Do you know why would I get an error massage "Unable to get the Match property of the WorksheetFunction class"? Is there anyway to fix this? I've tried different search terms that I no that are in he column but I still get this error
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top