starsky
06-11-2009, 05:07 AM
Hello everyone,
I'm fairly new to VBA, but I have a macro that creates new worksheets, & copies the header from the main data sheet. This works fine, and the header row to C&P to the new sheets is specified in the macro.
What I want to do is have a userform assigned to the macro. The user will input the row (from the main data sheet) that should be used as the header row on the new worksheets.
At the moment this code is used to apply the header row on the new sheets. How do I get a value from the userform to row 1 of the new sheet?
'Copies row 3 of main data page
Rows("3:3").Select
Selection.Copy
'creates new excel worksheet & names it
Set oSheet = Worksheets.Add
With oSheet
.Name = "sheetname"
Rows("1:1").Select
ActiveSheet.Paste
Also, how do I code a Cancel button so that the macro is exited (i.e. not just unloading the form).
Many thanks.
I'm fairly new to VBA, but I have a macro that creates new worksheets, & copies the header from the main data sheet. This works fine, and the header row to C&P to the new sheets is specified in the macro.
What I want to do is have a userform assigned to the macro. The user will input the row (from the main data sheet) that should be used as the header row on the new worksheets.
At the moment this code is used to apply the header row on the new sheets. How do I get a value from the userform to row 1 of the new sheet?
'Copies row 3 of main data page
Rows("3:3").Select
Selection.Copy
'creates new excel worksheet & names it
Set oSheet = Worksheets.Add
With oSheet
.Name = "sheetname"
Rows("1:1").Select
ActiveSheet.Paste
Also, how do I code a Cancel button so that the macro is exited (i.e. not just unloading the form).
Many thanks.