macro

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

don76

Thread Starter
Joined
Aug 1, 2006
Messages
5
hello

i am trying my hand at writing macros
i am trying to write a simple macro but running into simple errors
can u help me figure out wht is the probelm

Sub FollowME()
Dim myRange As Range
Set myRange = Sheet(1).Range("A1")
myRange.Hyperlinks.Add_
Anchor:=myrange,_
Address:=''http://search.yahoo.com?/bin/serch",_
Screen tip:="Search Yahoo",_
TextToDisplay:="click here"

End Sub
 

OBP

Joined
Mar 8, 2005
Messages
19,895
Two ways you can help yorself and us help you.
1. Add some error handling like the one below so that at least what type of errors you are getting.

'Sub Name goes here

On Error GoTo ErrorMessage

'Your Code goes here

Exit_Worksheet_Change:
Exit Sub

ErrorMessage:
MsgBox Err.Description
Resume Exit_Worksheet_Change

'End Sub goes here

2. Record a maro of doing what you want to do to see how Excel does it.
 
Joined
Jul 1, 2005
Messages
8,546
1. You need Sheets, not Sheet, i.e.:

Set myRange = Sheets(1).Range("A1")

2. Ditch the space in Screen Tip ; and you had 2 singlequotes before http instead of a double ; and your line-breaking is off, i.e.:

myRange.Hyperlinks.Add Anchor:=myRange, _
Address:="http://search.yahoo.com?/bin/serch", _
ScreenTip:="Search Yahoo", TextToDisplay:="click here"
 
Joined
Oct 26, 2005
Messages
354
As an aid to your work, perhaps it would be good in VBE to go to Tools > Options make sure the following are checked:

Auto Syntax check
Require Variable Declaration
Auto List Members

Each of these will assist you in writing code.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top