Save WorkSheet as per Cell VALUE (keep original open, and do not open new)

TTUK

Board Regular
Joined
Apr 5, 2012
Messages
137
Hello all,

I am trying to achieve the following within VBA.

1. Save specific worksheet (IIR_temp) to a location shown in the cell in A1 on that page, which is a reference from another sheet =IIR_data!5 which looks like (\\server\report\test.xls)
2. Then have the sheet just be saved, and not to override the current spreadsheet which is open


At present this is what I have:

ActiveSheet.Copy ' Copies active sheet to a new workbook
ActiveSheet.SaveAs Range("A1").Value, xlOpenXMLWorkbookMacroEnabled


I just don't know how to get the formula to save the certain sheet in the specified location shown in A1, and allow me to return as I was in the original spreadsheet.

Hope someone can help me out on this.

Thank you!
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Please do not PM the link, it needs to be posted to this thread in accordance with the forum rules.
Cheers
 
Upvote 0
Thanks for the file
Change this line as shown
Code:
ActiveWorkbook.SaveAs Range("A1").Value & Range("B1").Value [COLOR=#ff0000]& ".xls"[/COLOR], 56
and that worked for me.
However this will not save in the Air 501 etc folder. To do that you'll need to change IIR_temp B2 to look at IIR_Data A6 rather than A10.
 
Upvote 0
Hi Fluff,

I'm still getting the error, when I click to RUN the option of creating the IIR_temp it opens up a new Worksheet (Book1) for example, then an error appear of:

Run-time error '9'
Subscript out of range

I select Debug and shows the following code with the red text highlighted in yellow:

Code:
Public Sub Create_Links()


    Dim lastRow As Long
    Dim cell As Range
    
    'Create hyperlinks in column AW for each cell in column AW starting at AW8
    
[COLOR=#ff0000]    With Worksheets("Register")[/COLOR]
        lastRow = .Cells(Rows.Count, "B").End(xlUp).Row
        For Each cell In .Range("A8:A" & lastRow)
            .Hyperlinks.Add anchor:=.Cells(cell.Row, "AW"), Address:="", TextToDisplay:="Create " & cell.Value & " folder"
        Next
    End With
    
End Sub

Thanks,
 
Upvote 0
When you say
Code:
 when I click to RUN the option of creating the IIR_temp
Do you mean when you select a cell in col AY on sheet Register, or are you running the macro some otherway?
 
Upvote 0
When you say
Code:
 when I click to RUN the option of creating the IIR_temp
Do you mean when you select a cell in col AY on sheet Register, or are you running the macro some otherway?

Sorry I mean when I select the cell in AY which I require to have the follow-up form created for I get the error above.

Thank you,
 
Upvote 0
Not sure why you get that, as it's working ok in the workbook you supplied, but try this
Code:
    With [COLOR=#ff0000]ThisWorkbook[/COLOR].Worksheets("Register")
 
Upvote 0
Not sure why you get that, as it's working ok in the workbook you supplied, but try this
Code:
    With [COLOR=#ff0000]ThisWorkbook[/COLOR].Worksheets("Register")


YES! Fluff you are brilliant - this is now working completely as intended!

Many thanks, have a good rest of your day!

Regards,
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,375
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top