+ Reply to Thread
Results 1 to 5 of 5

Need Urgent Help with Macro to send data across instead of down.

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    oak park, mi
    MS-Off Ver
    Office 2016
    Posts
    20

    Need Urgent Help with Macro to send data across instead of down.

    Please help me solve this problem. I have had assistance before and the macro written works perfectly however I don't know how to adjust for different size data... see attached file called "Excel Problem looking for Help".
    Option Explicit
    Sub test()
    
    Dim lrow As Long, newlrow As Long, maxcoladd As Long, data, DOBstart As Long, MEMend As Long, result, n As Long, icounter As Long, z As Long, _
    i As Long, temp, j As Long, k As Long, m As Long, t As Integer
    
    lrow = Cells(Rows.Count, 1).End(xlUp).Row
    If lrow = 1 Then Exit Sub
    
    Application.ScreenUpdating = 0
    
    With Range("a1", Cells(Rows.Count, Cells(1, Columns.Count).End(xlToLeft).Column).End(xlUp))
        .Sort key1:=Range("a1"), Header:=xlYes
        .Subtotal 1, xlCount, 1
        newlrow = Cells(Rows.Count, "b").End(xlUp).Row - 1
        maxcoladd = Application.Max(Range("b1:b" & newlrow))
        ActiveSheet.UsedRange.RemoveSubtotal
        Columns(1).Delete
        data = .Value
    End With
    
    DOBstart = 2 + maxcoladd * 6
    MEMend = 8 + maxcoladd * 6
    
    ReDim result(0 To lrow, 1 To MEMend)
    
    result(0, 1) = "FacilityProperName"
    
    For n = 2 To 1 + maxcoladd * 6 Step 6
        icounter = icounter + 1
        result(0, n) = "MEM" & icounter
        result(0, n + 1) = "DOB" & icounter
        result(0, n + 2) = "Charla" & icounter
        result(0, n + 3) = "Renee" & icounter
        result(0, n + 4) = "MCN" & icounter
        result(0, n + 5) = "NPI" & icounter
    Next
    
    z = 8
    
    For n = DOBstart To MEMend
        result(0, n) = data(1, z)
        z = z + 1
    Next
    
    For i = 2 To lrow
        If temp = data(i, 1) Then
            For t = 2 To 7
                result(j, k) = data(i, t)
                k = k + 1
            Next
        Else
            temp = data(i, 1)
            j = j + 1
            For k = 1 To 7
                result(j, k) = data(i, k)
            Next
            m = 8
            For n = DOBstart To MEMend
                result(j, n) = data(i, m)
                m = m + 1
            Next
            k = 8
        End If
    Next
    
    With Sheets.Add.Range("a1").Resize(j + 1, MEMend)
        .Value = result
        .EntireColumn.AutoFit
        .Borders.LineStyle = xlContinuous
        .Resize(1).Interior.Color = RGB(219, 229, 241)
    End With
    
    Application.ScreenUpdating = 1
    
    End Sub
    Last edited by Leith Ross; 09-18-2014 at 09:57 PM. Reason: Added Code Tags

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need Urgent Help with Macro to send data across instead of down.

    Hello rzcb,

    Your file didn't attach. You should try attaching it again.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    oak park, mi
    MS-Off Ver
    Office 2016
    Posts
    20

    Re: Need Urgent Help with Macro to send data across instead of down.

    attached file- sorry
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Need Urgent Help with Macro to send data across instead of down.

    hi rzcb, if I understood your request correctly, press Run button or run code "test"(ALT+F8, select "test", press Run). Try to decrease/increase number of columns after the Date of Service column.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    oak park, mi
    MS-Off Ver
    Office 2016
    Posts
    20

    Re: Need Urgent Help with Macro to send data across instead of down.

    I attempted to delete and add columns however I kept receiving an error see attached image.
    Attached Images Attached Images

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [URGENT][Help with a VBA Macro - Maximum with criterias][URGENT]
    By mahmoudmerhi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2013, 03:39 PM
  2. if a date expires then send email with the row!Urgent!!!
    By bogdand in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2013, 05:17 AM
  3. Macro to compare main row of data URGENT
    By bb86993 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-21-2013, 10:23 AM
  4. (Urgent) Macro output different for different data sets - Please help
    By supershanks in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2013, 07:36 AM
  5. URGENT! Please please help me get smtp mail send working..
    By Duncan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2006, 09:55 AM

Tags for this Thread

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