Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Mpls, Minnesota, USA
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    analyze cells & make entries (Excel 97 SR2)

    I am working on a workbook and need some VBA help.
    A report is made that will vary in length. I want a macro that will enter information in column N depending on the contents of column M. Small sample workbook is attached.

    I can get the cursor to the lowest cell that needs the information (in the example it is N13). I would like a macro that checks the contents of the cell to the left (M) and if it is blank put a P in col N for that row then do the same thing for the cells above until all are processed through row 6. If the cell in M is not blank put the first character of what is in column M into column N.
    I have done it manually for the example. The results are in the range N6:N13.
    Any help will be appreciated as I prefer not to do it with a formula.
    Thanks,
    Chuck
    Chuck Reimer
    I'm from the Government and I'm here to help...

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: analyze cells & make entries (Excel 97 SR2)

    Does this do what you want?

    <pre>Public Sub FixColN()
    Dim I As Long
    For I = Worksheets("Reports").Range("A65536").End(xlUp).Ro w - 1 To 5 Step -1
    If Range("M1").Offset(I, 0).Value = "" Then
    Range("N1").Offset(I, 0).Value = "P"
    Else
    Range("N1").Offset(I, 0).Value = Left(Range("M1").Offset(I, 0).Value, 1)
    End If
    Next I
    End Sub
    </pre>



    However, you can also do this by putting the formula below in N6 and copying it down to the last possible row of the report:

    <pre>=IF(A6<>"",IF(M6<>"",LEFT(M6,1),"P"),"")
    </pre>

    Legare Coleman

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Mpls, Minnesota, USA
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: analyze cells & make entries (Excel 97 SR2)

    Legare,

    It sure does! Works very slick. Thank you.
    Sorry for the delayed response, but I was in a meeting.

    Chuck
    Chuck Reimer
    I'm from the Government and I'm here to help...

Posting Permissions

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