Hi There,
I have currently build the below mentioned macros.
Baiscally the first macro would assign a counter to a specific cell(E4)and this macro needs to loop based on cell(E2)value ie. if E2 = 37, then this macro should run 37 times by assigning value from 1 until 37 to cell E4.
Upon assigning a a counter to Cell E4 in "Control" Sheet, the second macro would
unhide row in "Statment" Sheet and the data is refreshed.
Finally the activesheet ie "Statement" needs to be saved in excel 2003 Version.
The above 3 macros should be consolidated and run multiple times depending upon the
cell value in E2 in "Control Sheet".
Just need a little help to tweak the code and make it work.
Thanks
Krishna
Sub Choose_Cell()
' This macro assigns Counter to a specific cell and based
' on the value in the cell, the "Statement" Sheet data refreshes.
Sheets("Control").Activate
Range("E4").Select
ActiveCell.FormulaR1C1 = "1"
Range("E4").Select
ActiveCell.FormulaR1C1 = "2"
End Sub
Sub Hide_unhide()
' This macro should trigger based on Choose_Cell macro and hide empty rows
Dim r As Range, cell As Range
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ThisWorkbook.Worksheets
If ws.Name = "Statement" Then
Set r = ws.Range("B20:B71")
For Each cell In r
If cell.Value = "" Then
cell.EntireRow.Hidden = True
Else
cell.EntireRow.Hidden = False
End If
Next cell
End If
Next ws
End Sub
Sub Create_file()
' This macro should copy the refreshed data in "Statement" Sheet and save as an excel 2003 version file.
Sheets("Statement").Copy
'Application.DisplayAlerts = False
With ActiveSheet.UsedRange
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With
Application.CutCopyMode = False
'ActiveWorkbook.SaveAs "Full Path/" & Format(Range("b10"), "mmm-dd-yy" & "HHMM" & ".xls")
ActiveSheet.SaveAs Filename:=Format(Range("b10") & ".xls")
'Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.ScreenUpdating = True
End Sub
Bookmarks