Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Im trying to work on a new worksheet using workbooks.add, but when i
try to put some data on this new workbook, the data fills the original workbook, where my macro is. this is my macro: cenario = Sheet1.Range("cdimportacao") Workbooks.Add Dim hoje As Date Dim sfilename As String sfilename = Format(Now(), "ddmmyyyy") hoje = Format(Now(), "dd/mm/yyyy") data = "DATA" Sheet1.Cells(1, 1).Value = data Sheet1.Cells(1, 2).Value = hoje Sheet1.Range("A1:E2545").Value = cenario ActiveWorkbook.SaveAs Filename:="c:\place\" & sfilename, _ FileFormat:=xlText, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Can someone help me with this? Appears to be basic. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi vkfuri-
I think you just need to make the workbook you add the "Active" workbook. Workbooks(Workbooks.Count).Activate You may also need to change Sheet1 to ActiveSheet. John "vkfuri" wrote: Im trying to work on a new worksheet using workbooks.add, but when i try to put some data on this new workbook, the data fills the original workbook, where my macro is. this is my macro: cenario = Sheet1.Range("cdimportacao") Workbooks.Add Dim hoje As Date Dim sfilename As String sfilename = Format(Now(), "ddmmyyyy") hoje = Format(Now(), "dd/mm/yyyy") data = "DATA" Sheet1.Cells(1, 1).Value = data Sheet1.Cells(1, 2).Value = hoje Sheet1.Range("A1:E2545").Value = cenario ActiveWorkbook.SaveAs Filename:="c:\place\" & sfilename, _ FileFormat:=xlText, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Can someone help me with this? Appears to be basic. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thats it, works great now.. thanks a lot.
|
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i didn't complete your entire macro, but you should always qualify your ranges,
especially if you use multiple workbooks. Sub test() Dim NewBook As Workbook Dim sfilename As String Dim hoje As Date Dim sdata As String Dim wb2 As Workbook Set wb2 = Workbooks.Add sfilename = Format(Now(), "ddmmyyyy") hoje = Format(Now(), "dd/mm/yyyy") sdata = "DATA" wb2.Worksheets("Sheet1").Cells(1, 1).Value = sdata wb2.Worksheets("Sheet1").Cells(1, 2).Value = hoje End Sub -- Gary "vkfuri" wrote in message ... Im trying to work on a new worksheet using workbooks.add, but when i try to put some data on this new workbook, the data fills the original workbook, where my macro is. this is my macro: cenario = Sheet1.Range("cdimportacao") Workbooks.Add Dim hoje As Date Dim sfilename As String sfilename = Format(Now(), "ddmmyyyy") hoje = Format(Now(), "dd/mm/yyyy") data = "DATA" Sheet1.Cells(1, 1).Value = data Sheet1.Cells(1, 2).Value = hoje Sheet1.Range("A1:E2545").Value = cenario ActiveWorkbook.SaveAs Filename:="c:\place\" & sfilename, _ FileFormat:=xlText, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Can someone help me with this? Appears to be basic. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Link one worksheet in a workbook to another worksheet in same work | Excel Discussion (Misc queries) | |||
Retrieving data into worksheet from another worksheet in same work | Excel Discussion (Misc queries) | |||
How does a module of VB work in a Worksheet? | Excel Worksheet Functions | |||
Copying the active worksheet to another worksheet in the same work | Excel Worksheet Functions | |||
I need a work around for a protected worksheet | Setting up and Configuration of Excel |