Opening workbook using a sheet name

  • I'm making a summary workbook. Each worksheet name represents a workbook. I want to then set the workbook I have just opened as 'refbk', though I am having trouble.


    Code
    Sub lookup_macro()
    'sht2fill.name = o271120b
    
    Dim sht2fill As Worksheet: Set sht2fill = ActiveSheet
    Dim refbk As Workbook
    P253_Open (sht2fill.Name) 'opens o271120b.xlsb
    Set refbk = (sht2fill.Name) & ".xlsb"
    
    End Sub
  • School boy error, solved now;


    Code
    Sub lookup_macro()
    'sht2fill.name = o271120b
    
    Dim sht2fill As Worksheet: Set sht2fill = ActiveSheet
    Dim refbk As Workbook
    P253_Open (sht2fill.Name) 'opens o271120b.xlsb
    Set refbk = Workbooks(sht2fill.Name & ".xlsb")
    
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!