free hit counter

Friday, September 08, 2006

gettin crazy with the VBA

crazy spreadsheet action around here. A pair of VBA functions to go through several formated child sheets to generate a plain text (data filterable) summary.


Sub Summarize(aSheetName)
'
' Summarize Macro
' Macro recorded 9/8/2006 by rsanderson
'

Sheets(aSheetName).Select
Range("C8").Select

Do
'copy the current cell and its east neighboor
Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 1)).Select
Selection.Copy

'paste into the summary sheet
Sheets("Summary").Select
ActiveCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


'move to the next col in the summary sheet to prep for next data in this row
ActiveCell.Offset(0, 2).Select

'go back to original sheet and copy the other three cols
Sheets(aSheetName).Select
Range(ActiveCell.Offset(0, 23), ActiveCell.Offset(0, 25)).Select
Selection.Copy

'paste into the summary sheet
Sheets("Summary").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'move to next row to wait for next paste command on the summary sheet
ActiveCell.Offset(1, -2).Select

'change back to orignal sheet and go to next candidate cell
Sheets(aSheetName).Select
ActiveCell.Offset(3, -23).Select


Loop Until IsEmpty(ActiveCell)

Sheets("Summary").Select

End Sub
Sub summarizeAllRegs()
'
' Macro written 8/2006 by rsanderson
'
' Keyboard Shortcut: Ctrl+p
'
Summarize ("System Commands")
Summarize ("SV02 Commands")
Summarize ("Pressure Commands")
Summarize ("FW Commands")


End Sub

Labels:

0 Comments:

Post a Comment

<< Home