Results 1 to 6 of 6

VBA to populate data / merging data & If Blank populate data

Threaded View

  1. #1
    Registered User
    Join Date
    03-18-2011
    Location
    Dayton, ME, USA
    MS-Off Ver
    Excel 2004 for MAC 11.5.4
    Posts
    77

    VBA to populate data / merging data & If Blank populate data

    Hi

    I hope someone can help, I just don't seem to be able to produce a macro that will work for the problem I have.

    I have a macro that works great below:-

     
    Sub MergeRows()
    Dim LR As Long, Rw As Long
    Dim delRNG As Range
    
    ActiveSheet.Copy
    Rows(1).WrapText = True
    Rows(2).Font.Bold = True
     Selection.sort Key1:=Range("AO2"), Order1:=xlAscending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Set delRNG = Range("A" & LR + 10)
    
    For Rw = LR To 2 Step -1
        If Range("AO" & Rw) = Range("AO" & Rw - 1) Then
            Range("AT" & Rw - 1) = Range("AT" & Rw) & "/" & Range("AT" & Rw - 1)
        
            Set delRNG = Union(Range("A" & Rw), delRNG)
        End If
    Next Rw
    
    delRNG.EntireRow.Delete xlShiftUp
    ActiveSheet.Name = "Ship List"
    
    Selection.sort Key1:=Range("AT2"), Order1:=xlAscending, Key2:=Range("BB2" _
            ), Order2:=xlAscending, Key3:=Range("L2"), Order3:=xlAscending, Header _
            :=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        
    End Sub

    Now I need to make some additions to this to make the following changes :-

    1. Insert 5 columns at the start, in the header row call these (in this order)
    Col A = Service Reference
    Col B = Service
    Col C = Service Enhancement
    Col D = Service Format
    Col E = Service Class

    2. Every row (with existing data) in the sheet then needs to be populated with the following data:

    Col A = 1
    Col B = PK1
    Col C = blank
    Col D = P
    Col e = 1st

    3. I then need to merge the surname into the first name column so we have first name and last name together (cols P and Q)


    4. In Col V I need it to If cell = United Kingdom make the cell blank but If cell = France, change to FR


    5. For Col AD (weight) if col V is blank populate 750 but if Col V shows FR then populate 220


    Iv'e been searching for answers for days and trying different options but I am completely stuck.


    I have attached the raw data example sheet and an example of how the results should look also.


    All help is appreciated.


    Many thanks

    Jon
    Attached Files Attached Files
    Last edited by endoskeleton; 09-08-2011 at 01:19 PM.

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