Forum Discussion

mtlbooks's avatar
mtlbooks
Copper Contributor
Mar 06, 2023

conditionel goto command in vba

Hi experts, i want to create a button on my sheet, which will take me conditionally to the next step.

if the first is not complete it will take me back to the first step (i don't want to use the hyperlink formula)

so, I want to do something like a conditional gotocell macro, and assign it on a shape.

(in the picture, just if first and last names are entered i want it should take me back to the next sheet, if not it shold take me back to the empty fields)

 

As a hyperlink I would write something like this: =HYPERLINK("#"&IF(I10="","Name!I10",IF(I14="","Name!I14","details!a1")),"Next>")

 

    • mtlbooks's avatar
      mtlbooks
      Copper Contributor

        I want it to be non-editable. I don't want to lock the cell because I wanna set the locked cells to be non-selectable!.JKPieterse 

      • mtlbooks's avatar
        mtlbooks
        Copper Contributor

        ā€‹  Hi , no need i figured the commend my self. 

        here is it:

         

        Sub variables()
        
            If IsEmpty(Range("i10")) Then
            
                Application.Goto Reference:=Worksheets("name").Range("i10"), _
         scroll:=True
                
            ElseIf IsEmpty(Range("i14")) Then
            
                Application.Goto Reference:=Worksheets("name").Range("i14"), _
         scroll:=True
         
         Else
            
               Application.Goto Reference:=Worksheets("details").Range("A3"), _
         scroll:=True
            
            End If
            
        End Sub

        mtlbooks 

Resources