Consulting

Results 1 to 2 of 2

Thread: Solved: Change to variable

  1. #1

    Solved: Change to variable

    Hi there,

    How can i change the following so that instead of saving my whole workbook, it just saves a specific sheet? The sheet i want to save varies though but is identified in my variable sSheetName.

    [vba]ActiveWorkbook.SaveAs Filename[/vba]

    [VBA]Dim sSheetName As String

    On Error Resume Next
    sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G125"), 2, False)
    On Error GoTo 0
    [/VBA]

    Thanks

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Dim sSheetName As String

    On Error Resume Next
    sSheetName = Application.VLookup(Range("K10").Value, Range("F117:G125"), 2, False)
    On Error GoTo 0
    Worksheets(sSheetName).Copy
    ActiveWorkbook.SaveAs Filename
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •