excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 291
- Office Version
- 365
- Platform
- Windows
Below is VBA code that works exactly as I need it to. The button to launch the code is located on a worksheet called "DASHBOARD". The values are inserted on a worksheet called "ACTIVITIES". When the user clicks on the button, the screen flashes from the "DASHBOARD" worksheet to the "ACTIVITIES" worksheet and back. I would like to eliminate that, and have the screen just remain on the "DASHBOARD" worksheet.
I know the code is not the cleanest, I am just learning VBA. I am guessing there is a way to activate the code without the need to go to the other worksheet. Can you suggest any modifications? Thanks so much.
I know the code is not the cleanest, I am just learning VBA. I am guessing there is a way to activate the code without the need to go to the other worksheet. Can you suggest any modifications? Thanks so much.
VBA Code:
Sub Phone1()
'
' Enter 1 for Phone Selection
'
Dim rStart As Range
If IsEmpty(Sheets("ACTIVITIES").Range("A2")) = True Then
Sheets("ACTIVITIES").Select
Range("A2").Select
ActiveCell = Sheets("Data").Range("B1")
ActiveCell.Offset(0, 1) = Sheets("Data").Range("D1")
End If
If Application.Sum(Range("E2:H2")) = 0 Then
Range("B2").Offset(0, 4).Value = 1
Else
Set rStart = Sheets("ACTIVITIES").Columns("C").Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Offset(0, 9)
If Application.Sum(rStart.Resize(, 32).Value) = 0 Then
Application.Goto Sheet1.Range("A1")
MsgBox "Select Activity for last record"
Else
Sheets("ACTIVITIES").Select
Range("C1").Select
Columns("C").Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious).Offset(1, 2).Select
ActiveCell.Value = 1
ActiveCell.Offset(0, -4).Select
If ActiveCell = "" Then
ActiveCell = Sheets("Data").Range("B1")
ActiveCell.Offset(0, 1) = Sheets("Data").Range("D1")
End If
End If
End If
Sheets("DASHBOARD").Select
Range("A1").Select
End Sub
Last edited by a moderator: