Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Macro Modification help needed

I have tried reworking my macro in different ways, but can't get it to do
what I need. How can I change the macro below so that it will start pasting
the information in Column B instead of Column A?

Private Sub Workbook_Open()
lr = Application.Max(2, Cells(Rows.Count, 2).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Workbooks("QIC.xls").Worksheets("Overturns_QIC")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 2 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "y") = 30 Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
..Rows(i).Copy Rows(dlr)
Next i
With Workbooks("FI.xls").Worksheets("Overturns_FI")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 2 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "y") = 30 Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
..Rows(i).Copy Rows(dlr)
Next i
End With
End With
End Sub

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro Modification help needed

Your code is copying Rows. You can't copy and row and then paste it into a
range object. They are different sizes. In excel 2003 you only have 256
columns. If you copy a row of 256 columns and paste starting at column B
only 255 columns are available and you will get an error.

Make this change. Similar change is required in two locations in the code

from
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
.Rows(i).Copy Rows(dlr)

to
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
LastColumn = .cells(i,columns.count).end(xltoleft).Column
Set CopyRange = .Range(.Range("B" & i),.cells(i,LastColumn))
CopyRange.Copy Destination:=Range("B" & dlr)

"akemeny" wrote:

I have tried reworking my macro in different ways, but can't get it to do
what I need. How can I change the macro below so that it will start pasting
the information in Column B instead of Column A?

Private Sub Workbook_Open()
lr = Application.Max(2, Cells(Rows.Count, 2).End(xlUp).Row)
'MsgBox lr
Rows("2:" & lr).ClearContents
With Workbooks("QIC.xls").Worksheets("Overturns_QIC")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 2 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "y") = 30 Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
.Rows(i).Copy Rows(dlr)
Next i
With Workbooks("FI.xls").Worksheets("Overturns_FI")
slr = .Cells(Rows.Count, "c").End(xlUp).Row
'MsgBox slr
For i = 2 To slr
dlr = Cells(Rows.Count, "a").End(xlUp).Row + 1
' If .Cells(i, "y") = 30 Then .Rows(i).Copy Rows(dlr)
If .Cells(i, "y") = 30 And Not .Cells(i, "x") = "Paid" Then
.Rows(i).Copy Rows(dlr)
Next i
End With
End With
End Sub

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assistance needed with Macro Modification akemeny Excel Programming 7 November 6th 08 01:16 PM
Ron De Bruin Code modification needed when naming copied worksheet Corey Excel Programming 2 July 14th 06 02:54 AM
Macro Compiles Sheets to One Book...Small Modification Needed TEAM[_7_] Excel Programming 1 September 15th 05 06:12 PM
need help with macro modification please excelguru Excel Programming 0 September 14th 05 08:18 PM
Formula Modification Needed Phil Hageman[_3_] Excel Programming 4 December 18th 03 07:19 PM


All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"