This is probably a really basic one for the wizards on here.
I'm trying to format a particular cell in a worksheet by calculating it from information entered and the code I have for that part works fine. By entering a name I get a cell reference such as Y5
in another cell. I'm trying to select that value (the cell address) as the defined variable celref
. Then on the worksheet I want updated, I want the cell from celref
to receive the assigned formatting. The code I'm using is:
Sub confirm()
Dim NAM As String
Dim celref As String
Worksheets("Morning").Select
NAM = Range("C3").Value
celref = Range("D3").Value
answer = MsgBox("Confirm sign in for " + NAM, vbYesNo + vbQuestion, "Confirm Sign In")
If answer = vbNo Then GoTo Bye
Worksheets("details").Select
Range(celref).Select '<========= This is where I get the error!
With Selection.Font
.ThemeColor = xlThemeColorDark1
.TintAndShade = 0
End With
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Font.Bold = True
There's some more code afterwards but it appears to be the range select which is causing the problem. Which newbie error am I making please?