Macro copying data from worksheet from certain columns within same workbook

jleone

New Member
Joined
Mar 2, 2011
Messages
5
I'm trying to copy data from a "DATA" worksheet within my main workbook. The data I'm trying to get is from only certain columns by name (i.e, "OH" column, "Trigger" column, "Max Inv" Column, etc.) On the "DATA" sheet I want to be able to find the column and select all of the data below (from row 2 until the end of the data) and copy this information.

Since this data is updated daily, the length of the rows for the data varies. I want to be able to grab the data from that day for each of the columns and paste them into a corresponding seperate sheet, where each sheet holds daily information for one column only (where this is a "OH" sheet, "Trigger" sheet, etc., where within these sheets the dates go from left (most recent) to right in the Columns for that sheet, AKA I would need to insert a column before the most recent data column)

I know this may confuse you, as you are not fully aware of the project I'm working on, but any help will be greatly appreciated.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
try this macro (modify if necessary)

Code:
Sub test()
Dim x(1 To 3) As String, cfind As Range, j As Integer
x(1) = "OH"
x(2) = "trigger"
x(3) = "max inv"
For j = 1 To 3
With Worksheets("main")
Set cfind = .Cells.Find(what:=x(j), lookat:=xlWhole)
If Not cfind Is Nothing Then
Range(cfind.Offset(1, 0), cfind.End(xlDown)).Copy
Worksheets.Add
ActiveSheet.Name = x(j)
ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
End If
End With
Next j
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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