PC Review


Reply
Thread Tools Rate Thread

Appending Hyperlink to existing text at certain start row

 
 
Matt Pierringer
Guest
Posts: n/a
 
      26th Feb 2007
Ok my code works great except I need to start at row 11, I am not sure
how to keep it so I am only going through the current range of column
a and to be able to start at a specified row
Here is my code:
Sub TextWithAppendedHyperlink()
Dim cell As Range
Dim txt$, url$
Dim colorTxt, colorUrl&

For Each cell In Worksheets(1).UsedRange.Columns(1).Cells
If cell <> "" And cell.Offset(0, 11).Value <> "" Then '
url = cell.Offset(0, 11).Value '"http://www.google.com"
colorUrl = ActiveWorkbook.Styles("Hyperlink").Font.Color
cell.Hyperlinks.Add _
Anchor:=cell, Address:= _
url, TextToDisplay:=Trim(cell.Value)
End If
Next
End Sub

Thanks for any help, It is much appreciated!

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      26th Feb 2007
Matt,

Try something like this:

Sub Test()
Dim c As Range
Dim iColStart As Integer
Dim iColEnd As Integer
Dim lRowStart As Long
Dim lRowEnd As Long
Dim rng As Range

With Sheet1.UsedRange
lRowEnd = .SpecialCells(xlCellTypeLastCell).Row 'Get the last row
If lRowEnd >= 11 Then 'Row 11 and above has data. keep going
lRowStart = 11 'Start from Row 11
iColStart = .Column 'Get the starting column
iColEnd = .SpecialCells(xlCellTypeLastCell).Column 'Get the last
column
Set rng = Range(Cells(lRowStart, iColStart), Cells(lRowEnd,
iColEnd))
For Each c In rng
If c.Value <> "" Then
'**************
'YOUR CODE HERE
'**************
End If
Next c
End If
End With
Set rng = Nothing
Set c = Nothing
End Sub



"Matt Pierringer" wrote:

> Ok my code works great except I need to start at row 11, I am not sure
> how to keep it so I am only going through the current range of column
> a and to be able to start at a specified row
> Here is my code:
> Sub TextWithAppendedHyperlink()
> Dim cell As Range
> Dim txt$, url$
> Dim colorTxt, colorUrl&
>
> For Each cell In Worksheets(1).UsedRange.Columns(1).Cells
> If cell <> "" And cell.Offset(0, 11).Value <> "" Then '
> url = cell.Offset(0, 11).Value '"http://www.google.com"
> colorUrl = ActiveWorkbook.Styles("Hyperlink").Font.Color
> cell.Hyperlinks.Add _
> Anchor:=cell, Address:= _
> url, TextToDisplay:=Trim(cell.Value)
> End If
> Next
> End Sub
>
> Thanks for any help, It is much appreciated!
>
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Appending text data to existing table Richard Microsoft Access VBA Modules 4 12th Jun 2008 01:56 PM
appending text to existing values anny Microsoft Excel Worksheet Functions 3 28th Jan 2006 06:24 PM
Tool for appending to an existing text file with a few keystrokes? Iain Cheyne Freeware 8 23rd Feb 2005 10:39 PM
Appending form text into hyperlink Gabriel Microsoft Frontpage 1 9th Mar 2004 10:08 PM
Appending XML to existing XmlDocument Jesper Stocholm Microsoft C# .NET 4 11th Nov 2003 03:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:59 PM.