Thursday, August 25, 2016

How Can You Fix - Building a Report using a VBA Macro in Excel?

Building a Report using a VBA Macro in Excel

My boss has asked me to produce a report for him in Excel.
(It really should be in Access but he wants it in excel so I'm stuck doing it this way).
I have to do this everyweek and want to simplify the process.
I start with an excel sheet of data, that has the same colomns in the same order every time so cleaning up the data is pretty straight forward.
But then I have to break the data into subsets, put the same headers on the top of each subset, then subtotal
each subset.
The subsets will be different sizes and with different numbers of them each time so this part of the process is the variable I need to deal with.
Can I have some suggestions on how I might accomplish this? I'm thinking I'd start with a "Report Generating Spreadsheet" and use a macro in that workbook to produce the "Report Spreadsheet".
Any suggestions?

Keys to the Problem Building a Report using a VBA Macro in Excel

Download Error Fixer (Free)

Hi,
I guess this involves reading down a column and collecting grouped data together and then copying it to another location.
The macro below makes a start on that.
This line
V = Split("AAA,BBB,CCC", ",")
Contains the groups and instead of AAA etc they could be company names or whatever you like, you can add to the list but maintain the syntax.

The macro takes each of these in turn and reads down column A of sheet1 and at the end of each loop copies all like date which can then be pasted somewhere else.
Paste this test data into a1 of sheet 1.
I have included a command to stop the macro at the end of each loop so you can see what's happening


aaa
me
£999
formula

aaa
me
£1,000
formula

bbb
me
£1,001
formula

aaa
me
£1,002
formula

bbb
me
£1,003
formula

ccc
me
£1,004
formula

ccc
me
£1,005
formula

 
Sub Split_Sheet()
Dim MyRange, x As Long, LastRow As Long
Dim CopyRange As Range
Set sht = Sheets("Sheet1")
LastRow = sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = sht.Range("A1:A" & LastRow)
V = Split("AAA,BBB,CCC", ",")
For x = 0 To UBound(V)
    For Each c In MyRange
        If UCase(c.Value) = V(x) Then
            If CopyRange Is Nothing Then
                Set CopyRange = c.EntireRow
            Else
                Set CopyRange = Union(CopyRange, c.EntireRow)
            End If
        End If
        If Not CopyRange Is Nothing Then
            CopyRange.Copy
            'Do something with data
        End If
           
    Next
stop
    Set CopyRange = Nothing
Next
End Sub

If this post answers your question, please mark it as the Answer.
Mike H

To install drivers and other optional updates

  1. To install optional updates, you need to review and then select them from the list of updates that Windows finds for your computer. Optional updates are not installed automatically.
  2. Open Windows Update by clicking the Start button Picture of the Start button, clicking All Programs, and then clicking Windows Update.
  3. In the left pane, click Check for updates, and then wait while Windows looks for the latest updates for your computer.
  4. If any updates are found, click View available updates.
  5. Select the optional updates that you want, and then click Install. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

Recommended Method to Repair the Problem: Building a Report using a VBA Macro in Excel:

How to Fix Building a Report using a VBA Macro in Excel with SmartPCFixer?

1. Download Error Fixer. Install it on your system.

2. After the scan is done, you can see the errors and problems which need to be repaired.

3. The Fixing part is finished, the speed of your computer will be much higher than before and the errors have been fixed.


Related: How to Download Toshiba Portege R500 HDD/SSD Alert Utility v.2.2.0.0 driver,Way to Update & Download Toshiba Satellite A355-S69403 Motorola Modem Region Select Utility v.2.2.3.0 driver,Where to Download Toshiba Satellite L305-S5926 HW Setup Utility v.2.00.11 driver,[Solved] Download Toshiba Satellite L675-S7115 Laptop Checkup v.2.0.6.22 driver,Method to Download Toshiba Satellite M645-S4080 Media Controller v.1.1.88.1 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17
Read More: Fast Solution to Problem: Browsing Issues with Internet Explorer,Troubleshooting:C:\\WINDOWS\\SYSTEM32\\INETCPL.CPL IS NOT A WIN 32 APPLICATION.,[Solution] Cable Modem w\/Router? - What is the advantage of having a router with my cable modem?,Solution to Problem: BSOD and stop error codes after windows update,[Solution] Bluetooth Mouse Not Detectable,All diagnostic tools give 0x800700C1, troubleshooting wizard can't continue,all files try to open with adobe,all icons on desktop have changed to Adobe icon and won't open,All functions of my outlook are working except it will not let me "REPLY" or start a "NEW" email,all f1-f12 shortcuts not work

No comments:

Post a Comment