View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Die_Another_Day Die_Another_Day is offline
external usenet poster
 
Posts: 644
Default Help with method

Try this:
Dim Equity As Range
Dim sCell As Range '"Search Cell"

For I = 1 To 35
Sheets("Menu").Select
Country = Cells(39 + I, 3).Value
If Country = Empty Then GoTo 7
Sheets("Portfolio Valuation").Select
Set Equity = Cells.Find("Equity")
If Not Equity Is Nothing Then
sCell = Cells.Find(What:=Country, After:=Equity, _
LookAt:=xlWhole)
If Not sCell Is Nothing Then
sCell.Activate
ActiveCell.Font.Bold = True
Selection.EntireRow.Insert
Selection.EntireRow.Insert
End If
End If
Next I
The main problem was that you forgot the ' before the comment in the
Dim statement. As a general rule, Dim statements should always be at
the top of your code. Also you can't have two next I statements, the
easiest work around is to put a jump in there, however in your case it
wasn't needed, but here's how to do it just in case:
For i = 1 to 10
if i 5 then
Goto SkipToNext
Else
msgbox i
end if
SkipToNext:
Next i

HTH

Die_Another_Day
CarolineHedges wrote:
Apologies, this should say:

For I = 1 To 35

Sheets("Menu").Select
Country = Cells(39 + I, 3).Value
If Country = Empty Then GoTo 7
Sheets("Portfolio Valuation").Select
Cells.Find("Equity").Select
Dim Equity As Range
Dim sCell As Range "Search Cell"
Set Equity = ActiveCell
sCell = Cells.Find(What:=Country, After:=Equity, _
LookAt:=xlWhole)
If sCell Is Nothing Then
Next I
Else
sCell.Activate
ActiveCell.Font.Bold = True
Selection.EntireRow.Insert
Selection.EntireRow.Insert
End If

Next I

But it still doesn't like the bit in red, or the next I bit in red,
which i should perhaps replace with activecell.select


--
CarolineHedges
------------------------------------------------------------------------
CarolineHedges's Profile: http://www.excelforum.com/member.php...o&userid=35705
View this thread: http://www.excelforum.com/showthread...hreadid=566055