+ Reply to Thread
Results 1 to 4 of 4

ultiple if Statements

  1. #1
    Newman Emanouel
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Newman Emanouel
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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. #4
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1