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
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".
Keys to the Problem Building a Report using a VBA Macro in Excel
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.
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
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
Set CopyRange = Union(CopyRange, c.EntireRow)
If Not CopyRange Is Nothing Then
'Do something with data
Set CopyRange = Nothing
If this post answers your question, please mark it as the Answer.
To install drivers and other optional updates
- 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.
- Open Windows Update by clicking the Start button Picture of the Start button, clicking All Programs, and then clicking Windows Update.
- In the left pane, click Check for updates, and then wait while Windows looks for the latest updates for your computer.
- If any updates are found, click View available updates.
- 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.126.96.36.199 driver,Way to Update & Download Toshiba Satellite A355-S69403 Motorola Modem Region Select Utility v.188.8.131.52 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.184.108.40.206 driver,Method to Download Toshiba Satellite M645-S4080 Media Controller v.220.127.116.11 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