Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Add multiple IF statements

Got a code that works exactly how I like....
Need to add addtional if statements.
The range (h3:h) remains the same, but just need to know how to add a
few more If statments in a code.


Sub macro200()
Dim c As Range
Dim rng As Range
Dim ws As Worksheet

Set ws = Worksheets("Sheet1")
Set rng = ws.Range("h3:h" & ws.Cells(ws.Rows.Count,
"h").End(xlUp).Row)
For Each c In rng
If c.Value = Range("ao2").Value Then
c.Offset(0, 1).Value = c.Offset(0, 33).Value
End If
Next c

End Sub



thanx

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Add multiple IF statements

Don't know what you want to test for, but this should give you an
idea.
Sub macro200()
Dim c As Range
Dim rng As Range
Dim ws As Worksheet

Set ws = Worksheets("Sheet1")
Set rng = ws.Range("h3:h" & ws.Cells(ws.Rows.Count,
"h").End(xlUp).Row)
For Each c In rng
If c.Value = Range("ao2").Value Then
c.Offset(0, 1).Value = c.Offset(0, 33).Value
ElseIf c.Value = Range("bo2").Value Then
c.Offset(0, 1).Value = c.Offset(0, 34).Value
ElseIf c.Value = Range("co2").Value Then
c.Offset(0, 1).Value = c.Offset(0, 35).Value
Else
c.Offset(0, 1).Value = c.Offset(0, 36).Value
End If
Next c
End Sub

J.W. Aldridge wrote:
Got a code that works exactly how I like....
Need to add addtional if statements.
The range (h3:h) remains the same, but just need to know how to add a
few more If statments in a code.


Sub macro200()
Dim c As Range
Dim rng As Range
Dim ws As Worksheet

Set ws = Worksheets("Sheet1")
Set rng = ws.Range("h3:h" & ws.Cells(ws.Rows.Count,
"h").End(xlUp).Row)
For Each c In rng
If c.Value = Range("ao2").Value Then
c.Offset(0, 1).Value = c.Offset(0, 33).Value
End If
Next c

End Sub



thanx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Add multiple IF statements

Any other way to write that?

I tried it and it didnt work for me.

I blocked the other if statements (placed ' before each line and
changed Else If to "If" on one line at a time) out and ran each line
individually and it worked fine.

Thanx


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
Multiple If Statements Tigerwould Excel Worksheet Functions 6 May 16th 08 11:49 AM
Multiple IF statements looking up multiple ranges. mike Excel Worksheet Functions 7 August 9th 07 04:55 PM
Multiple if statements with multiple conditions egarcia Excel Discussion (Misc queries) 4 January 29th 07 10:46 PM
Multiple IF statements Matt Excel Programming 1 December 8th 05 02:36 PM
multiple if statements Alex McKenzie Excel Discussion (Misc queries) 3 November 21st 05 09:35 AM


All times are GMT +1. The time now is 08:19 AM.

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"