DJKennyDubs
New Member
- Joined
- Nov 21, 2022
- Messages
- 11
- Office Version
- 365
- Platform
- Windows
Hello all,
I am attempting to combine two Workbook Subs that were written before into one Master Intersect sub that will .Select the cell upon user input.
First things first...
Now for the code:
First One checks all worksheets within the book for the only cell turned green (=today()) and sets the cursor location to that cell.
Next one asks the user to input their Last Name immediately upon Worksheet Open, and then the cursor location is set to that cell (Goto).
What I'm TRYING to do is combine the two processes with an INTERSECT.select that will take the Column of the cell identified in the FindAndExecute sub and the Row of the cell identified by the Workbook_Open Sub so that
A) The Workbook asks for the Last Name upon Workbook Opening
B) The Cell that intersects with today()+the User's Last Name is focused on/selected and ready for input
I feel like I'm soooo close but the answer is just eluding me. Thanks in advance for the assistance! This community has helped me learn so much!
I am attempting to combine two Workbook Subs that were written before into one Master Intersect sub that will .Select the cell upon user input.
First things first...
Now for the code:
First One checks all worksheets within the book for the only cell turned green (=today()) and sets the cursor location to that cell.
VBA Code:
Sub FindAndExecute()
Dim Sh As Worksheet
Dim Loc As Range
For Each Sh In ThisWorkbook.Worksheets
With Sh.UsedRange
Set Loc = Application.FindFormat.Interior.Color = rgbGreen
If Not Loc Is Nothing Then
Do Until Loc Is Nothing
Set Loc = .FindNext(Loc)
Loop
End If
End With
Set Loc = Nothing
Next
End Sub
Next one asks the user to input their Last Name immediately upon Worksheet Open, and then the cursor location is set to that cell (Goto).
VBA Code:
Private Sub Workbook_Open()
Dim FindString As String
Dim Rng As Range
FindString = InputBox("Enter your Last Name")
If Trim(FindString) <> "" Then
With ActiveSheet.Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub
What I'm TRYING to do is combine the two processes with an INTERSECT.select that will take the Column of the cell identified in the FindAndExecute sub and the Row of the cell identified by the Workbook_Open Sub so that
A) The Workbook asks for the Last Name upon Workbook Opening
B) The Cell that intersects with today()+the User's Last Name is focused on/selected and ready for input
I feel like I'm soooo close but the answer is just eluding me. Thanks in advance for the assistance! This community has helped me learn so much!
Last edited by a moderator: