View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Appending Hyperlink to existing text at certain start row

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!