Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default ultiple if Statements

Hello

I need a little help with some vb code.

I have a excel sheet with multiple columns. One particular column has
account numbers say column "A" I need to write some code that will look at
column "A" and if for example cell A1 has "5120" in it then add the word Rent
into Columb "B".

It sounds really simple but I am having a lot of problems in executing. Any
help with some code would be very appreciated.

Thanks

Regards

Newman

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ultiple if Statements

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i,"A").Value = 5120 Then
Cells(i,"B").Value = "Rent"
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Newman Emanouel" wrote in message
...
Hello

I need a little help with some vb code.

I have a excel sheet with multiple columns. One particular column has
account numbers say column "A" I need to write some code that will look at
column "A" and if for example cell A1 has "5120" in it then add the word

Rent
into Columb "B".

It sounds really simple but I am having a lot of problems in executing.

Any
help with some code would be very appreciated.

Thanks

Regards

Newman



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default ultiple if Statements

Bob

Thanks this works great but, I need to incorporate the case statement as
there are multiple account numbers to code. For example 5120, 5215, 6587 all
belong to the "Wages" category. Can you help please


"Bob Phillips" wrote:

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i,"A").Value = 5120 Then
Cells(i,"B").Value = "Rent"
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Newman Emanouel" wrote in message
...
Hello

I need a little help with some vb code.

I have a excel sheet with multiple columns. One particular column has
account numbers say column "A" I need to write some code that will look at
column "A" and if for example cell A1 has "5120" in it then add the word

Rent
into Columb "B".

It sounds really simple but I am having a lot of problems in executing.

Any
help with some code would be very appreciated.

Thanks

Regards

Newman




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default ultiple if Statements

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i,"A").Value = 5120 Then
Cells(i,"B").Value = "Rent"
ElseIf Cells(i,"A").Value = 5215 Then
Cells(i,"B").Value = "Food"
'etc
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Newman Emanouel" wrote in message
...
Bob

Thanks this works great but, I need to incorporate the case statement as
there are multiple account numbers to code. For example 5120, 5215, 6587

all
belong to the "Wages" category. Can you help please


"Bob Phillips" wrote:

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Cells(i,"A").Value = 5120 Then
Cells(i,"B").Value = "Rent"
End If
Next i

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Newman Emanouel" wrote in message
...
Hello

I need a little help with some vb code.

I have a excel sheet with multiple columns. One particular column has
account numbers say column "A" I need to write some code that will

look at
column "A" and if for example cell A1 has "5120" in it then add the

word
Rent
into Columb "B".

It sounds really simple but I am having a lot of problems in

executing.
Any
help with some code would be very appreciated.

Thanks

Regards

Newman






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
Max if statements instereo911 via OfficeKB.com Excel Discussion (Misc queries) 5 October 29th 08 05:32 PM
if then statements Mercy Excel Worksheet Functions 2 June 9th 08 12:17 AM
IF Statements (Mutliple Statements) Deezel Excel Worksheet Functions 3 October 19th 06 06:13 AM
Counting ultiple constants in cell Westy Excel Discussion (Misc queries) 4 August 8th 06 07:53 PM
operator statements, shorting when reusing one of the statements? KR Excel Programming 1 August 4th 05 06:20 PM


All times are GMT +1. The time now is 03:14 PM.

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

About Us

"It's about Microsoft Excel"