Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 111
Default macro with If statement not working

i have taken an existing macro that loops and am trying to tailor it to my
needs. here is what i want to do
1. go to cell ai225
2. check the contents of t225
3. if t225 = General Research then put "MIT0000" in cell ai225
4. move to the next row and perform the same operation.

when i run the macro i get an error notice "End If without Block if". Any
ideas.

here is the macro

sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"

Do Until myRow = 10

End If
ActiveCell.Offset(1, 0).Select

myRow = myRow + 1

Loop

End Sub

thanks in advance for your help
aprilshowers
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default macro with If statement not working

Maybe...

Option Explicit
Sub loopthrough()
Dim myRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
FirstRow = 10
LastRow = .Cells(.Rows.Count, "T").End(xlUp).Row

For iRow = FirstRow To LastRow
If LCase(.Cells(iRow, "T").Value) = LCase("General Research") Then
.Cells(iRow, "ai").Value = "MIT0000"
End If
Next iRow
End With

End Sub

=========
If this is a one time shot, you may want to do it manually.

Filter your data by column T.
Show the rows that have "general research" in that column
Select the range of visible rows in column AI
Edit|goto (or hit F5)|Special|visible cells only
type:
MIT0000
and hit ctrl-enter to fill those visible cells with the new value.



april wrote:

i have taken an existing macro that loops and am trying to tailor it to my
needs. here is what i want to do
1. go to cell ai225
2. check the contents of t225
3. if t225 = General Research then put "MIT0000" in cell ai225
4. move to the next row and perform the same operation.

when i run the macro i get an error notice "End If without Block if". Any
ideas.

here is the macro

sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"

Do Until myRow = 10

End If
ActiveCell.Offset(1, 0).Select

myRow = myRow + 1

Loop

End Sub

thanks in advance for your help
aprilshowers


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,646
Default macro with If statement not working

Try this way (not tested, but the cause of error is eliminated)

Sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
Do Until myRow = 10
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"
End If
ActiveCell.Offset(1, 0).Select
myRow = myRow + 1
Loop

End Sub

Regards,
Stefi


€žapril€ť ezt Ă*rta:

i have taken an existing macro that loops and am trying to tailor it to my
needs. here is what i want to do
1. go to cell ai225
2. check the contents of t225
3. if t225 = General Research then put "MIT0000" in cell ai225
4. move to the next row and perform the same operation.

when i run the macro i get an error notice "End If without Block if". Any
ideas.

here is the macro

sub loopthrough()
Dim myRow As Integer
myRow = 1

Range("AI225").Select
If ActiveCell.Offset(0, -15).Range("a1").Select = "Karlan-Gine" Then
ActiveCell = "MIT0000"

Do Until myRow = 10

End If
ActiveCell.Offset(1, 0).Select

myRow = myRow + 1

Loop

End Sub

thanks in advance for your help
aprilshowers

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement not working steve12173 Excel Worksheet Functions 7 June 18th 09 06:44 PM
IF Statement not working Barrett M Excel Worksheet Functions 8 May 6th 08 03:29 PM
If statement working only once Lime Excel Worksheet Functions 0 May 5th 08 03:58 AM
If Statement Not Working Telegirl Excel Worksheet Functions 9 May 12th 07 04:34 PM
IF statement not working TJAC Excel Discussion (Misc queries) 2 January 13th 06 01:08 PM


All times are GMT +1. The time now is 06:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"