+ Reply to Thread
Results 1 to 7 of 7

Need advice on data processing formulas in Excel 2010

Hybrid View

  1. #1
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Need advice on data processing formulas in Excel 2010

    robinc1969,

    In reference to your workbook:


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    1. Copy the below code, by highlighting the code and pressing the keys CTRL + C
    2. Open your workbook
    3. Press the keys ALT + F11 to open the Visual Basic Editor
    4. Press the keys ALT + I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Where the cursor is flashing, paste the code by pressing the keys CTRL + V
    7. Press the keys ALT + Q to exit the Editor, and return to Excel
    8. To run the macro from Excel, open the workbook, and press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.


    
    Option Explicit
    Option Base 1
    Sub ReorgData()
    ' stanleydgromjr, 01/14/2013
    ' http://www.excelforum.com/newreply.php?do=postreply&t=890900
    Dim i As Variant, o As Variant, r As Long, s As Long
    i = Range("E5").CurrentRegion
    ReDim o(1 To UBound(i, 1) / 2, 1 To 3)
    For r = 1 To UBound(i, 1) Step 2
      s = s + 1
      o(s, 1) = i(r, 1)
      o(s, 3) = i(r + 1, 1)
    Next r
    Range("G4").Resize(UBound(o, 1), UBound(o, 2)) = o
    Range("G4").Resize(UBound(o, 1)).NumberFormat = "0.00"
    End Sub

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the ReorgData macro.


    I will be back in a little while with another slightly modified macro.


    Have a great day,
    Stan
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: Need advice on data processing formulas in Excel 2010

    robinc1969,

    The following macro creates two separate arrays for columns G and I, instead of one array for columns GHI. I was not sure what column H is being used for.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).


    
    Option Explicit
    Sub ReorgDataV2()
    ' stanleydgromjr, 01/14/2013
    ' http://www.excelforum.com/newreply.php?do=postreply&t=890900
    Dim e As Variant, g As Variant, i As Variant, lr As Long, r As Long, s As Long
    e = Range("E5").CurrentRegion
    lr = Cells(Rows.Count, "G").End(xlUp).Row
    If lr > 3 Then Range("G4:G" & lr).ClearContents
    lr = Cells(Rows.Count, "I").End(xlUp).Row
    If lr > 3 Then Range("I4:I" & lr).ClearContents
    ReDim g(1 To UBound(e, 1) / 2, 1 To 1)
    ReDim i(1 To UBound(e, 1) / 2, 1 To 1)
    For r = 1 To UBound(e, 1) Step 2
      s = s + 1
      g(s, 1) = e(r, 1)
      i(s, 1) = e(r + 1, 1)
    Next r
    Range("G4").Resize(UBound(i, 1)) = g
    Range("G4").Resize(UBound(i, 1)).NumberFormat = "0.00"
    Range("I4").Resize(UBound(i, 1)) = i
    End Sub

    Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm


    Then run the ReorgDataV2 macro.


    Have a great day,
    Stan

  3. #3
    Registered User
    Join Date
    01-14-2013
    Location
    Greenville, SC
    MS-Off Ver
    Excel 2016
    Posts
    26

    Thumbs up SOLVED -- Need advice on data processing formulas in Excel 2010

    Stan, both worked perfectly. What exactly is the difference in the two? As long as they both capture any occupied fields in column E this is what I have been looking for. You've saved me a LOT of time in my job. Thank you!

+ Reply to Thread

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