ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Worksheets (https://www.excelbanter.com/excel-worksheet-functions/257189-worksheets.html)

Donna[_2_]

Worksheets
 
Could you possibly have a solution for me. My information is downloaded into
excel. When it does it gives the workbook a number as the name of the
worksheet. I run a macro and that's no problem, but I wanting to use an
additional macro that will add additional worksheets and do other
calculations. When I try to add the additional worksheets or reference the
numbered worksheet, it won't do it because of the unique number is assigns
each time I download the report. Donna Hauff

Dave Peterson

Worksheets
 
If your running the code with that workbook activated and the single worksheet
as the activesheet, you could use:

Dim wkbk as workbook
dim wks as worksheet

set wkbk = activeworkbook 'or workbooks("somenamehere") if you know the name

set wks = activesheet
or just use the first (and only) worksheet in that workbook
set wks = wkbk.worksheets(1)

Then you can add new worksheets to that workbook and use the data from the
original worksheet (say):

Dim wkbk as workbook
dim wks as worksheet
dim newSht as worksheet
set wkbk = activeworkbook 'or workbooks("somenamehere") if you know the name
set wks = wkbk.worksheets(1)
set newsht = wkbk.worksheets.add

newsht.range("A1").value = wks.range("x99").value 'or whatever

Donna wrote:

Could you possibly have a solution for me. My information is downloaded into
excel. When it does it gives the workbook a number as the name of the
worksheet. I run a macro and that's no problem, but I wanting to use an
additional macro that will add additional worksheets and do other
calculations. When I try to add the additional worksheets or reference the
numbered worksheet, it won't do it because of the unique number is assigns
each time I download the report. Donna Hauff


--

Dave Peterson


All times are GMT +1. The time now is 09:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com