Hi there,
I've searched and searched and everything I try doesn't work for me & I'm going to have to give up and ask for help.
The code below is part of a larger code but this is the part thats not working as intended. I've added the full code at the bottom for reference.
I've not written this from scratch. It's a patchwork of many help files, forums and other peoples work that I have adapted to suit my needs.
Been working flawlessly for 3-4 years now. Just wanted to add some extra automation to it.
Part code. (Line commented out so it's easy to find)
ANS is derived from an input box.
ANS selection is a serial number selected from column B.
Code search's for serial number selected from column B in T3:T72. When found it highlights certain cells grey and inserts a date.
Works like a charm providing its all on the same sheet.
Doesn't work if the input box selection is on one sheet and serial its looking for is on another. There are no more than 6 sheets at any time in the workbook.
So basically I think it's this line that needs something.
I've been trying things like
And so on.
Am I on the correct path here?
Thanks
Dave
Full code. (Line commented out so it's easy to find)
I've searched and searched and everything I try doesn't work for me & I'm going to have to give up and ask for help.
The code below is part of a larger code but this is the part thats not working as intended. I've added the full code at the bottom for reference.
I've not written this from scratch. It's a patchwork of many help files, forums and other peoples work that I have adapted to suit my needs.
Been working flawlessly for 3-4 years now. Just wanted to add some extra automation to it.
Part code. (Line commented out so it's easy to find)
VBA Code:
ActiveSheet.Range(ANS.Offset(, 0), ANS.Offset(, 0)).Select
Dim rCell As Range
Dim rRng As Range
'For Each rCell In Range("T3:T72")
If rCell.Value = (ANS) Then
If rRng Is Nothing Then
Set rRng = rCell
Else
Set rRng = Application.Union(rRng, rCell)
End If
End If
Next
ActiveSheet.Range(rRng.Offset(, 0), rRng.Offset(, 20)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
ActiveSheet.Range(rRng.Offset(, 12), rRng.Offset(, 12)).Value = Date
ANS is derived from an input box.
ANS selection is a serial number selected from column B.
Code search's for serial number selected from column B in T3:T72. When found it highlights certain cells grey and inserts a date.
Works like a charm providing its all on the same sheet.
Doesn't work if the input box selection is on one sheet and serial its looking for is on another. There are no more than 6 sheets at any time in the workbook.
So basically I think it's this line that needs something.
VBA Code:
For Each rCell In Range("T3:T72")
I've been trying things like
VBA Code:
Range("$T$3:$T$72")
Range("Sheet1:Sheet2!$T$3:$T$72")
Range(("Sheet1, Sheet2)$T$3:$T$72"))
And so on.
Am I on the correct path here?
Thanks
Dave
Full code. (Line commented out so it's easy to find)
VBA Code:
Sub SIGNOFF()
Dim ANS As Range
On Error GoTo CANCELED
Set ANS = Application.InputBox("Which Chair do you wish to mark as complete?" & vbNewLine & "Please select chair serial number ", "Completion Notification", Type:=8)
If MsgBox("You are about to sign off " & ANS & " as complete. Are you sure?", vbYesNo) = vbNo Then Exit Sub
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Select
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Font.Name = "3DS LIGHT"
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Font.Bold = True
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 3005476
.TintAndShade = 0
.PatternTintAndShade = 0
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = " This wheelchair has passed final inspection and is ready for despatch"
.Item.to = ""
.Item.CC = ""
.Item.bcc = "*******@rgkwheelchairs.com"
.Item.Subject = "**RGK CHAIR COMPLETION ALERT** " & ANS & " / " & ANS.Offset(, -1) & " / " & ANS.Offset(, 2) & " is ready for despatch "
.Item.send
End With
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Font.Name = "ARIAL"
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 2)).Font.Bold = False
ActiveSheet.Range(ANS.Offset(, -1), ANS.Offset(, 14)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.499984740745262
.PatternTintAndShade = 0
ActiveSheet.Range(ANS.Offset(, 3), ANS.Offset(, 3)).Font.Name = "wingdings"
ActiveSheet.Range(ANS.Offset(, 3), ANS.Offset(, 3)) = "ü"
ActiveSheet.Range(ANS.Offset(, 5), ANS.Offset(, 11)).Font.Name = "wingdings"
ActiveSheet.Range(ANS.Offset(, 5), ANS.Offset(, 11)) = "ü"
ActiveSheet.Range(ANS.Offset(, 0), ANS.Offset(, 0)).Select
Dim rCell As Range
Dim rRng As Range
' For Each rCell In Range("T3:T72")
If rCell.Value = (ANS) Then
If rRng Is Nothing Then
Set rRng = rCell
Else
Set rRng = Application.Union(rRng, rCell)
End If
End If
Next
ActiveSheet.Range(rRng.Offset(, 0), rRng.Offset(, 20)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.249977111117893
.PatternTintAndShade = 0
ActiveSheet.Range(rRng.Offset(, 12), rRng.Offset(, 12)).Value = Date
ActiveWorkbook.Save
Range("A1").Select
CANCELED:
End With
End With
End With
End Sub
Last edited: