PC Review


Reply
Thread Tools Rate Thread

Add multiple IF statements

 
 
J.W. Aldridge
Guest
Posts: n/a
 
      4th Oct 2007
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

 
Reply With Quote
 
 
 
 
JW
Guest
Posts: n/a
 
      4th Oct 2007
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


 
Reply With Quote
 
J.W. Aldridge
Guest
Posts: n/a
 
      4th Oct 2007
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 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
Multiple Update Set Statements or Multiple DML Statements in one thedudeminds@msn.com Microsoft Access Queries 4 11th Sep 2007 06:34 PM
Multiple IF statements looking up multiple ranges. =?Utf-8?B?bWlrZQ==?= Microsoft Excel Worksheet Functions 7 9th Aug 2007 04:55 PM
multiple statements updating a table with multiple values =?Utf-8?B?TWlsbGJyb29rIFNjaG9vbA==?= Microsoft Access Queries 2 23rd Feb 2007 01:53 PM
Multiple if statements with multiple conditions =?Utf-8?B?ZWdhcmNpYQ==?= Microsoft Excel Misc 4 29th Jan 2007 10:46 PM
Multiple If Statements =?Utf-8?B?SkM=?= Microsoft Excel Programming 3 7th Sep 2006 12:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:02 AM.