Excel VBA Create a link to another worksheet only if a cell is populated

Tony_Y

New Member
Joined
May 29, 2020
Messages
35
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to create a button that I will click and it will transfer me to another worksheet but only if a cell is populated. If the cell is not populated I want a message box to warn me and not go any further until the cell is populated. I have so far done this but it just takes me to sheet 14 with no message box. Any help will be greatly appreciated.

Sub checkIfCellIsEmpty()

If ThisWorkbook.Sheets(16).Range("R5").Value = "" Then
MsgBox "CURRENT UIN MUST BE ENTERED"

Else

Sheet14.Activate

End If
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try that

Dim Cell As Range
For Each Cell In Range("R5")

If IsEmpty(Cell.Value) = True Then
MsgBox (" CURRENT UIN MUST BE ENTERED .")
Cancel = True
Else
Sheet14.Activate
Exit Sub
End If
Next Cell
 
Upvote 0
Are you looking at the correct sheet?
Should it be the 16th sheet from the left, a sheet called "16" or maybe the codename Sheet16?
 
Upvote 0
Hi Arcadius and Fluff,

Sorry for late reply but yes that works great. That delivers exactly what I wanted. Many thanks or you help it is greatly appreciated.

Regards

Tony
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top