Thread: moving data
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
holyman holyman is offline
external usenet poster
 
Posts: 23
Default moving data

Otto

Many thanks for that. Couple of pointers as I'm newish to coding.
I have the sheets already created i.e Power, Water etc.
The data i need moving from the raw data to the relevant sheet is from
column M to BF.
WHn i have tried to run this, I get the debug error at 'For Each ShtName In
Range("SheetList")'. Do I need to write the names of the sheets into the
coding
Please help as I really would like to uderstand this, and this will help for
future stuff I need to do



"Otto Moehrbach" wrote:

Here is a macro that will do what you want. For this macro to operate
correctly the following conditions must exist:
The active sheet is the sheet that contains your raw data.
The raw data is in Columns A:C as you said.
There must a list of all the sheet names in some column of some sheet in
your file and that list must be named "SheetList".
Note that this macro copies Columns B:C and pastes that data into Column A
of the appropriate sheets.
Sub CopyData()
Dim ShtName As Range
Dim RngColA As Range
Dim i As Range
Dim Dest As Range
Set RngColA = Range("A2", Range("A" & Rows.Count).End(xlUp))
For Each ShtName In Range("SheetList")
With Sheets(ShtName.Value)
Set Dest = .Range("A" & Rows.Count).End(xlUp).Offset(1)
For Each i In RngColA
If Left(i, Len(ShtName.Value)) = ShtName.Value Then
i.Offset(, 1).Resize(, 2).Copy Dest
Set Dest = Dest.Offset(1)
End If
Next i
End With
Next ShtName
End Sub
"holyman" wrote in message
...
I have a massive list of raw data that I am wanting to put into individual
sheets. i.e
All those rows that start in column A with Powercar1 into sheet called
Power, same for WaterCar1 into Water etc. Snip it below of data
Is this possible.....I've had a look at the forum and can't find any clues
to help me.
I'm not wanting to copy and paste
If I put a formula into the first column of each sheet to lookup the
reference, I get the same data repeated...........it does not bring each
in.
If necessary data can be added to the raw data if it helps putting it into
seperate sheets. Please help


Column A Column B Column C

POWERCAR0 36 WF05XXGBB56T88939
POWERCAR0 36 WF05XXGBB56T89898
BTCAR0 35 WF05XXGBB56T89963
GOVERNMENT DEPARTMENTSCAR1 117 WF05XXGBB56Y39111
WATERCAR1 117 WF05XXGBB56Y39978
GOVERNMENT DEPARTMENTSCAR1 117 WF05XXGBB56Y40092
POWERCAR1 111 WF05XXGBB56Y45247
POWERCAR1 96 WF05XXGBB56Y48127
AFFILIATESCAR1 106 WF05XXGBB56Y48299