Results 1 to 2 of 2

Converting data from 4 columns in 1 row into a new value

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-31-2012
    Location
    Los Angeles, USA
    MS-Off Ver
    2003, 2010, 365
    Posts
    320

    Converting data from 4 columns in 1 row into a new value

    Hi,

    I'm in need of a way to convert data from each row to an item number, I have attached an example of a what I'm currently using but I need it the exact opposite.

    The code below is writing 39.3, 51, 31, 7 each time there is MPG-PB01, but I need the opposite which is to write MPG-PB01 each time there is 39.3, 51, 31, 7

    Dim c As Range, lr As String    'declare variables
        
    lr = Range("D6555").End(xlUp).Row   'set Lr equal to the last cell in column D that contains a value
     
    For Each c In Range("D1:D" & lr).Cells  'loops through cell in column D from row 1 to the last row
        Select Case c.Value 'if the current cell in the loop's value is...
            Case "MPG-PB02"   'MPG-PB02 then    (this is case sensitive)
                Range(Cells(c.Row, 5), Cells(c.Row, 8)).Value = Array(44, 42, 26, 9)    'with column E through H spread the array
            Case "MPG-PB01"
                Range(Cells(c.Row, 5), Cells(c.Row, 8)).Value = Array(39.3, 51, 31, 7)
            Case "MPS006"
                Range(Cells(c.Row, 5), Cells(c.Row, 8)).Value = Array(31, 27, 24, 7)
            Case "MPS007"
                Range(Cells(c.Row, 5), Cells(c.Row, 8)).Value = Array(32, 30, 24, 8)
            Case "MPS008"
                Range(Cells(c.Row, 5), Cells(c.Row, 8)).Value = Array(32, 28, 24, 7)
        End Select
    Next c  'move to next cell in the loop
    And I'm using excel 2003

    Hope this makes sense and that somebody can help.

    Thanks anyway,

    David
    Last edited by djfscouse; 02-12-2013 at 07:08 PM. Reason: mistake

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