delaney1102
New Member
- Joined
- Aug 14, 2019
- Messages
- 14
Hi all, I have created a macro (that I largely copied from an already existing one in the same workbook, I just needed some slightly different things done) in a workbook with about 15 tabs that takes data from an xl hidden tab and copies it over to a master file in another location, that all works fine. The issue I'm coming across is at the end of the code, I need to type some text in a specific cell on whichever of 2 tabs are currently visible. If Worksheet A is visible, then I want the text in J37 but if Worksheet A is hidden, then I can skip that and move to Worksheet B and type the text in J23. I've played around with some IFs and visible=true, but still coming across some errors. Any help is appreciated!
Application.ScreenUpdating = True
Worksheets("A").Select
Range("J37").Value = "TEXT " & Now()
Worksheets("B").Select
Range("J23").Value = "TEXT " & Now()
Worksheets("A").Protect "PASSWORD"
Worksheets("B").Protect "PASSWORD"
Application.CutCopyMode = False
Sheets("Z").Select
Range("A1").Select
MsgBox "JOB COMPLETE."
Exit Sub
Application.ScreenUpdating = True
Worksheets("A").Select
Range("J37").Value = "TEXT " & Now()
Worksheets("B").Select
Range("J23").Value = "TEXT " & Now()
Worksheets("A").Protect "PASSWORD"
Worksheets("B").Protect "PASSWORD"
Application.CutCopyMode = False
Sheets("Z").Select
Range("A1").Select
MsgBox "JOB COMPLETE."
Exit Sub