Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy sheets with variable sheetnames

Status
Not open for further replies.

mleosu

Technical User
Sep 26, 2006
56
US
I have some code that copies data and pastes it into new sheets - where the sheet names are variable depending on the data copied into them. Another thing about the code is that the number of new sheets will not always be the same - i could be from 1 new sheet to 4 new sheets.

I want to move the new sheets into a new workbook. I have an idea on how to figure out how many sheets there are and to figure out thier names - but the code is forever long. I was wondering if anyone had any ideas on how to do this - or get me started.

for entire code:
 
you might want to remove your company name from the code you have posted there.

Chance,

Filmmaker, gentleman and ROMAN!
 
you might in relation to what you are doing want to take a look at ranges , a lot of your code there already can be cut down.

Next have a look at teh workbook object and worksheets,

re arrange your code so it goes top to bottom

Workbook
Worksheet
Range

I think then you will see more clearly what you need to do to get to your next step

Chance,

Filmmaker, gentleman and ROMAN!
 
well, before i reconstruct my code - which yes, i am sure it could be reduced quite a lot - i just thought about establishing variable names for the main workbook and the new workbook (since neither will ever be constant) - this will help me go between the 2 at all times without using thier actual names in the code.

MAIN_WORKBOOK = ActiveWorkbook.Name
NEW_WORKBOOK = (CustomerChosen_SHEETNAME & " SLAs")
 
Aye good plan,

Also in regards to your formating you could then have something along the lines of

Sub subFormatColumns(wrkbk as workbook)

wrkbk.sheets(1).column(A).width = 3.45

end sub



Chance,

Filmmaker, gentleman and ROMAN!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top