Cursor Still not linked with Code

Rahul14181

New Member
Joined
Jul 24, 2017
Messages
6
Hey Everyone,

I found below link to select the name range on the basis of cell value Below code is working fine but i want that my cursor should be on the starting of the selected names range or first cell of names range like a hyperlink..

Can you please suggest me , what needs to be done in below code?

Sub test()




Application.ScreenUpdating = False




Dim Ash As Worksheet
Dim stxt1 As String
Dim stxt2 As String
Dim stxt3 As String




Set Ash = ActiveWorkbook.ActiveSheet




stxt1 = "AUSTRALIA"
stxt2 = "AUSTRIA"
stxt3 = "SINGAPORE"




If Ash.Range("J1") = stxt1 Then
With Ash
.Range("B10:L10").Select
End With
End If

If Ash.Range("J1") = stxt2 Then
With Ash
.Range("D10:E10").Select
End With
End If

If Ash.Range("J1") = stxt3 Then
With Ash
.Range("E10:F10").Select
End With
End If

Application.ScreenUpdating = True








End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hello,

I don't really understand what you mean by your cursor.
If you talk about he place where you write something in Excel, then your code already move it to a specific range.
If you talk about your mouse icon, even if it was possible to move it automatically (I don't know how), I would never recommend it.

On another note, I simplified your code.
Code:
Sub test()
Application.ScreenUpdating = False


If Range("J1") = "AUSTRALIA" Then
Range("B10:L10").Select
ElseIf Range("J1") = "AUSTRIA" Then
Range("D10:E10").Select
ElseIf Range("J1") = "SINGAPORE" Then
Range("E10:F10").Select
End If


Application.ScreenUpdating = True
End Sub
 
Upvote 0
It your wanting to select the top row of a named range try something like this:

Code:
Sub My_Names()
Range("Sam").Rows(1).Select
End Sub
 
Upvote 0
If you simply want to go to the 1st cell in your range try this
Code:
Sub Rng()
    Select Case Range("J1")
        Case "AUSTRALIA"
            Range("B10").Select
        Case "AUSTRIA"
            Range("D10").Select
        Case "SINGAPORE"
            Range("E10").Select
    End Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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