PDA

View Full Version : [SOLVED] Copy selected columns to new sheets.



pegbol
03-02-2005, 07:40 PM
.
Hello Masters,

I got the attached file from contextures.com The code of the file creates new Sheets for records of column C 'Rep'.

I would appreciate help me to include to this VBA code the next::help
To copy to new Sheets all the format of the sheet "template".
To copy to new Sheets the records of "Sheet1" only for the columns of the sheet "template".
To sort the column 'Item' of the new Sheets

Thanks so much in advance for your kind help.

regards,
Pedro.

PS. Could it be possible to add totals to columns 'Units' and 'Total' of the new sheets?.
.

Jacob Hilderbrand
03-02-2005, 08:03 PM
Try this macro.


Option Explicit

Sub Macro1()
Dim i As Long
Dim LastRow As Long
Dim Row As Long
Dim ws As Worksheet
With Sheets("Sheet1")
LastRow = .Range("A65536").End(xlUp).Row
For i = 2 To LastRow
On Error Resume Next
Set ws = Sheets(.Range("C" & i).Text)
If Err <> 0 Then
Sheets("Template").Copy After:=Sheets(Sheets.Count)
Set ws = Sheets(Sheets.Count)
ws.Name = .Range("C" & i).Text
End If
On Error GoTo 0
Row = ws.Range("B65536").End(xlUp).Row + 1
ws.Range("B" & Row).Value = .Range("C" & i).Text
ws.Range("C" & Row).Value = .Range("B" & i).Text
ws.Range("D" & Row).Value = .Range("E" & i).Value
ws.Range("E" & Row).Value = .Range("D" & i).Text
ws.Range("F" & Row).Value = .Range("G" & i).Value
Next i
End With
End Sub

pegbol
03-03-2005, 05:08 AM
.
Just Awesome!!!!!:clap: :clap: :clap:


As always. Thanks and thanks so much Jake!!!.:bow:


best and kindest regards,
Pedro
La Paz, BOLIVIA.
.

Jacob Hilderbrand
03-03-2005, 05:27 AM
You're Welcome :beerchug:

Take Care

pegbol
03-05-2005, 02:05 PM
.
Hello Jake,

I am not sure if it is correct to reopen a thread. If it's not, I apologize.

I made some corrrections to my template sheet and I tried to make a modification to the code. Unfortunately, I couldn`t.:banghead:

I can't leave empty the first row (of every new sheet).
I can't include a sum to the last row and include an operation to column F (of every new sheet).

So, one more time I kindly ask your valuable support.: pray2:

I enclose the code with a little modification I did it.

Thanks so much again for your help.

regards,
Pedro.
.