Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thankyou so much Norman, you've been a great help. The procedure works
perfectly now. Rob "Norman Jones" wrote in message ... Hi Rob, Try: '============= Sub ExportToMYOB() Dim WB As Workbook Dim WB2 As Workbook Dim SH As Worksheet Dim SH2 As works Dim rng As Range Dim newFileName As String Set WB = Workbooks("General-Journal1.xls") Set SH = WB.Sheets(1) '<<==== CHANGE Set SH2 = WB.Sheets(2) '<<==== CHANGE Set rng = SH2.Range("A1") '<<==== CHANGE newFileName = rng.Text SH.Copy Application.DisplayAlerts = False With ActiveWorkbook .SaveAs Filename:=newFileName, _ FileFormat:=xlText .Close End With Application.DisplayAlerts = True End Sub '<<============= --- Regards, Norman "Rob" wrote in message ... Hi Norman, Thankyou for your great procedure. It works brilliantly, but wonder if you could assist with a couple of matters which I've shown in the procedure (as I have it) below.... Sub ExportToMYOB() Dim WB As Workbook Dim WB2 As Workbook Dim SH As Worksheet Dim rng As Range Const newFileName As String = "See note -" 'I need this to be the value of a cell from one of the worksheets. How can that be done? Set WB = Workbooks("General-Journal1.xls") Set SH = WB.Sheets("Sheet3") 'When running the code it stops at this point and says "Subscript out of range unless I change it to the actual name of the sheet. Is there a way to refer simply to the sheet number? Set rng = SH.Range("A1") SH.Copy Application.DisplayAlerts = False With ActiveWorkbook .SaveAs Filename:=newFileName, _ FileFormat:=xlTextWindows .Close End With Application.DisplayAlerts = True End Sub Thank you for your time! Rob |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text File | Excel Discussion (Misc queries) | |||
Text records in Excel | Excel Discussion (Misc queries) | |||
Changing a comma separated text file and save it. | Excel Discussion (Misc queries) | |||
how can i convert text file to excel file ? | New Users to Excel | |||
Improrting Text file to a matrix when things are not constant. | Excel Worksheet Functions |