Results 1 to 4 of 4

Check a cell's value and populate other cells with varying data

Threaded View

  1. #1
    Registered User
    Join Date
    05-03-2010
    Location
    Texas, US
    MS-Off Ver
    Excel 2003
    Posts
    4

    Check a cell's value and populate other cells with varying data

    I have a spreadsheet with a column that has text, I need it to check to see if another column in the same row has text in it, then fill other cells in the same row but different columns accordingly.

    Basically a while loop with a case statement for each check, and the while loop tests if the cell has a value in it before processing, when it reaches the end of the data it stops, there will never be a blank cell before the end of the column.
    nRow = 3
    nCol = 3
     While (Cells(nRow,nCol))
     If ActiveSheet.Cells(nRow,(nCol-1)).Value = "Box"
       ActiveSheet.Cells(nRow,(nCol+1)).Value = "Virtual"
       ActiveSheet.Cells(nRow,(nCol+2)).Value = "Place1"
       ActiveSheet.Cells(nRow,(nCol+3)).Value = "Place2"
       ActiveSheet.Cells(nRow,(nCol-1)).Value = Range("B2") & " " & ActiveSheet.Cells(nRow,nCol)
     End if
     nRow=nRow+1
    wEnd
    B2 will be a number(text?) that will change with each sheet, but each time I run the macro it will be using the number from that cell on that sheet, and it's giving me problems.
    I know this code isn't exact, but I was doing it at work and I forgot to bring it with me, so this is a basic sketch of what I am working with.

    ..........A..........B.........C.........D........E.........F..........G
    1
    2...................90-91
    3....................Box.....System
    4...................Junct....Transf
    5....................Box.....System

    To become

    ............A............B.........C.........D.............E.........F..........G
    1
    2.....................90-91
    3..90-91.Box.....Box...System....Virtual....Place1.....Place2......
    4.....................Junct...Transf
    5..90-91.Box.....Box...System....Virtual....Place1.....Place2......

    It will always start at the same row+column, but it needs to go until it runs out of stuff in the column
    Last edited by Demosthenes&Locke; 05-05-2010 at 07:27 AM. Reason: Code tags required for VBA Code, Please read the Forum Rules

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