Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
C3 C3 is offline
external usenet poster
 
Posts: 13
Default Worksheet as file

Hi!

First, I have a .xls file (AAA.xls) with a single (base) worksheet
("Baza") - content of one cell (B1) is "0001". I want to copy this worksheet
(because I want to save data unchanged in base worksheet) and run macro
(etc."xxx") who will take some changes, save this "changed" worksheet as a
..xls file in format "Name0001.xls" and erase that "changed" worksheet. For
next time when I'll open AAA.xls cell (B1) must grow for one number (0002)
and next saved file must have this number "Name0002.xls" and so on...

Any suggestions?

C3


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Worksheet as file

Dim sh as Worksheet, sh1 as Worksheet
set sh = workbooks("AAA.xls").Worksheets("Baza")
sh.copy
set sh1 = Activesheet
Call xxx
sh1.parent.SaveAs Filename:=sh.parent.Path & "\Name" & _
sh1.Range("A1").Text & ".xls", Fileformat:=xlNormal
Sh1.parent.Close SaveChanges:=False
sh.Range("B1").Value = clng(sh.Range("B1").Value) + 1
sh.Parent.Close SaveChanges:=True


--
Regards,
Tom Ogilvy


"C3" wrote in message
...
Hi!

First, I have a .xls file (AAA.xls) with a single (base) worksheet
("Baza") - content of one cell (B1) is "0001". I want to copy this

worksheet
(because I want to save data unchanged in base worksheet) and run macro
(etc."xxx") who will take some changes, save this "changed" worksheet as a
.xls file in format "Name0001.xls" and erase that "changed" worksheet. For
next time when I'll open AAA.xls cell (B1) must grow for one number (0002)
and next saved file must have this number "Name0002.xls" and so on...

Any suggestions?

C3




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 280
Default Worksheet as file

'---------------------------
' In ThisWorkbook module
'---------------------------
Option Explicit

Private Sub Workbook_Open()
With ThisWorkbook.Sheets("Sheet1")
.Range("A1").Value = _
Val(.Range("A1").Text) + 1
End With
ThisWorkbook.Save
End Sub


'---------------------------
' In a standard module
'---------------------------
Option Explicit

'---------------------------
Sub ProcessWorksheet()
Application.ScreenUpdating = False
ChangeWorksheet
SaveWorksheetAsNewWorkbook
EraseWorksheet
Application.ScreenUpdating = True
End Sub

'---------------------------
Private Sub ChangeWorksheet()
'put code to change worksheet here
End Sub

'---------------------------
Private Sub SaveWorksheetAsNewWorkbook()
Dim strSavePath As String
Dim strSaveName As String
strSavePath = "K:\"

Dim wkb As Workbook
With ThisWorkbook.Sheets("Sheet1")
strSaveName = "Name"
strSaveName = strSaveName & _
Format(.Range("A1").Text, "0000")
strSaveName = strSaveName & ".xls"
.Copy
End With
Set wkb = ActiveWorkbook
wkb.SaveAs Filename:= _
strSavePath & strSaveName, _
FileFormat:=xlNormal
wkb.Close
End Sub

'---------------------------
Private Sub EraseWorksheet()
With ThisWorkbook.Worksheets("Sheet1")
Range(.Rows(2), .Rows(.Rows.Count)).Clear
End With
End Sub


"C3" wrote in message
...
Hi!

First, I have a .xls file (AAA.xls) with a single (base) worksheet
("Baza") - content of one cell (B1) is "0001". I want to copy this

worksheet
(because I want to save data unchanged in base worksheet) and run macro
(etc."xxx") who will take some changes, save this "changed" worksheet as a
.xls file in format "Name0001.xls" and erase that "changed" worksheet. For
next time when I'll open AAA.xls cell (B1) must grow for one number (0002)
and next saved file must have this number "Name0002.xls" and so on...

Any suggestions?

C3




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set up a worksheet name as file name Sunil Pal Excel Discussion (Misc queries) 1 March 21st 08 04:40 AM
Worksheet to new file jai Excel Discussion (Misc queries) 1 August 25th 07 07:36 AM
copy part of a worksheet into a worksheet in the same file/keepi. JTB Excel Worksheet Functions 1 September 23rd 06 09:13 AM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
open file dialog-select file-import worksheet Divinedar Excel Programming 1 January 16th 04 07:13 PM


All times are GMT +1. The time now is 04:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"