arok
arok

Reputation: 107

how to keep the first cell always active in excel using vba

How to keep the first cell always active when opening the excel sheet.

Can any one guide me to how to this.

This is my code:

       Private Sub Send_Click()
       Dim strURL As String
       strURL = "http://xxxxxxxxxxxx.com/excelAPI.php?customer_id=1&mobilenumber=" _
       & ActiveCell.Value & "&message=" & ActiveCell.Offset(0, 1).Value
       Call Sheets("Sheet1").WebBrowser4.Navigate(strURL)

       End Sub

Upvotes: 0

Views: 1631

Answers (1)

saru_
saru_

Reputation: 121

I'm not quite sure why you would want the first cell to be active. If it's just because you are using ActiveCell in your Code then you should be defining a Range instead. Like this:

Private Sub Send_Click()
   Dim strURL As String
   strURL = "http://xxxxxxxxxxxx.com/excelAPI.php?customer_id=1&mobilenumber=" _
   & Range("A1").Value & "&message=" & Range("A1").Offset(0, 1).Value
   Call Sheets("Sheet1").WebBrowser4.Navigate(strURL)
End Sub

Anyway. This is how you activate the first cell (A1) of YourWorksheet when the Workbook is opened:

Private Sub Workbook_Open() 
   Worksheets("YourWorksheet").Activate
   Range("A1").Activate
End Sub

Upvotes: 2

Related Questions