Worksheet reference issue?

Ray Rz

New Member
Joined
Jun 19, 2018
Messages
29
I have a macro that should run but I am linking it to cell N14 for the file name and cell N16 for the Worksheet tab name.
I cannot get this macro to run and it stops where I reference the worksheet name in cell N16.
If someone could look at this and possibly assist me, I would appreciate it.

Thank you,
Ray
------------------------------------------------

Code:
Sub Macro3(ws As Worksheet)




'
' Macro3 Macro
'
' Keyboard Shortcut: Ctrl+g
'


Workbooks.Open ws.Range("N14").Value
Worksheets wks.Range("N16").Activate
'
'
Dim wks As Excel.Worksheet


On Error Resume Next
    Set wks = ThisWorkbook.Worksheets(Sheets("Start").Range("N16").Value)
On Error GoTo 0


If Not wks Is Nothing Then
    Call wks.Activate
    
        'Worksheets("July 2018").Activate where the value of cell N16 is July 2018
        Range("A3").Select
    Selection.AutoFilter
    Columns("A:E").Select
    Selection.EntireColumn.Hidden = False
    Rows("3:3").Select
    Selection.AutoFilter
    ActiveCell.Offset(0, 0).Range("A2:BR26000").Select
        ActiveSheet.Range("$E2").AutoFilter Field:=5, Criteria1:= _
        "Haugland"
    Selection.Copy
    Windows("VBA Extractor r57with code V2.xlsm").Activate
    Worksheets("Const. Prog. Rpt Switches").Activate
    ActiveCell.Offset(0, 0).Range("A1").Select
    
    'ActiveCell.Offset(0, 0).Range("A2").Select
    
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False


Call refresh


'    End If


End Sub
 
Ok, how about
Code:
Worksheets(Ws.Range("N16").Text).Activate
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Thanks Fluff. Just had to tie the Worksheet into the Start!N16 for the tab to be selected correctly. Appreciate your constructive questions so I could figure this one out. Thank you very much.
Ray
 
Upvote 0
Glad you got it sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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