Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bob,
I have modified my code which is now below. I have tried to add a variable of mnthlgth as string and a number for each scenario to add a month under the resize option. I am getting an object required error. Can you see why? Thanks Rob Sub Addrows_Click() Dim iLastRow As Long Dim mnthlgth As String Dim wsArchive As Worksheet Set wsArchive = Workbooks("Archive.xls").Sheets(1) If ActiveSheet.Range("$A$4").Value = #1/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2008# Then ActiveSheet.Rows("4:32").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:32").Delete Set mnthlgth = 29 ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2012# Then ActiveSheet.Rows("4:32").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:32").Delete Set mnthlgth = 29 ElseIf ActiveSheet.Range("$A$4").Value = #2/1/2016# Then ActiveSheet.Rows("4:32").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:32").Delete Set mnthlgth = 29 ElseIf ActiveSheet.Range("$A$4") = #2/1/2005# Then ActiveSheet.Rows("4:31").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:31").Delete Set mnthlgth = 28 ElseIf ActiveSheet.Range("$A$4") = #3/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4") = #4/1/2005# Then ActiveSheet.Rows("4:33").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:33").Delete Set mnthlgth = 30 ElseIf ActiveSheet.Range("$A$4") = #5/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4") = #6/1/2005# Then ActiveSheet.Rows("4:33").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:33").Delete Set mnthlgth = 30 ElseIf ActiveSheet.Range("$A$4") = #7/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4") = #8/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4") = #9/1/2005# Then ActiveSheet.Rows("4:33").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:33").Delete Set mnthlgth = 30 ElseIf ActiveSheet.Range("$A$4") = #10/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 ElseIf ActiveSheet.Range("$A$4") = #11/1/2005# Then ActiveSheet.Rows("4:33").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:33").Delete Set mnthlgth = 30 ElseIf ActiveSheet.Range("$A$4") = #12/1/2005# Then ActiveSheet.Rows("4:34").Cut Destination:=wsArchive.Range("A65536").End(xlUp) ActiveSheet.Rows("4:34").Delete Set mnthlgth = 31 End If iLastRow = Cells(Rows.Count, "A").End(xlUp).Row Cells(iLastRow, "A").AutoFill Cells(iLastRow, "A").Resize(mnthlgth) End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
colating multi rows of data into single rows - no to pivot tables! | Excel Worksheet Functions | |||
Enabling option „Format rows“ to hide/unhide rows using VBA-code? | Excel Discussion (Misc queries) | |||
Counting characters in multiple rows when rows meet specific criteria | Excel Worksheet Functions | |||
Copy rows of data (eliminating blank rows) from fixed layout | Excel Discussion (Misc queries) | |||
Pivot Tables: How do I show ALL field rows, including empty rows?? | Excel Worksheet Functions |