Thecraftycarrot

New Member
Joined
Nov 8, 2018
Messages
27
Hi i am having issues with the following code The first half works fine(It copies, but doesn't paste), its just the second half that is causing me an issue - i am getting run time error 438 -object doesn't support this property or method.



Code:
Dim UpdateRow As Long
Dim UpdateCol As Long
Dim ColName As String
Dim S3 As Worksheet
Dim S2 As Worksheet
Dim S1 As Worksheet


Set S3 = Sheets("SHEET3")
Set S2 = Sheets("SHEET2")
Set S1 = Sheets("SHEET1")



        Rowname = S1.Range("E16").Value
        UpdateRow = S2.Range("A3:a1000").Find(Rowname, LookIn:=xlValues).Row
        ColName = "Contract number"
        UpdateCol = S2.Range("A2:AZ2").Find(ColName, LookIn:=xlValues).Column
        S2.Select
        S2.Range(Cells(UpdateRow, UpdateCol), Cells(UpdateRow, UpdateCol).Offset(0, 29).Address).Copy
        
        Rowname = ArchContract.Range("a10000").End(xlUp).Row
        ColName = "Contract line number"
        UpdateCol = ArchContract.Range("A2:AZ2").Find(ColName, LookIn:=xlValues).Column
        ArchContract.Select
        ArchContract.Cells(Rowname, UpdateCol).Paste
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
you did not say which line contains the error

but
instead of
Code:
S2.Range(Cells(UpdateRow, UpdateCol), Cells(UpdateRow, UpdateCol).Offset(0, 29)[COLOR=#ff0000].Address)[/COLOR].Copy
try
Code:
S2.Range(Cells(UpdateRow, UpdateCol), Cells(UpdateRow, UpdateCol).Offset(0, 29)).Copy
 
Upvote 0
What line gives the error?
Also what is ArchContract?
lso you need to change Paste to Pastespecial
 
Last edited:
Upvote 0
Hi Both, thanks for the quick responses!

Please see the amended code - the archcontract was one of the tabs in the file, that i should of renamed - s3 - please see the updated code below.

Code:
Dim UpdateRow As Long
Dim UpdateCol As Long
Dim ColName As String
Dim S3 As Worksheet
Dim S2 As Worksheet
Dim S1 As Worksheet


Set S3 = Sheets("SHEET3")
Set S2 = Sheets("SHEET2")
Set S1 = Sheets("SHEET1")



        Rowname = S1.Range("E16").Value
        UpdateRow = S2.Range("A3:a1000").Find(Rowname, LookIn:=xlValues).Row
        ColName = "Contract number"
        UpdateCol = S2.Range("A2:AZ2").Find(ColName, LookIn:=xlValues).Column
        S2.Select
        S2.Range(Cells(UpdateRow, UpdateCol), Cells(UpdateRow, UpdateCol).Offset(0, 29).Address).Copy
        
        Rowname = S3.Range("a10000").End(xlUp).Row
        ColName = "Contract line number"
        UpdateCol = S3.Range("A2:AZ2").Find(ColName, LookIn:=xlValues).Column
        S3.Select
        S3.Cells(Rowname, UpdateCol).Paste

Yongle the code you proposed is what i originally had, but an error kept appearing (cannot remember which error of the top of my head), but problem was resolved with the additional .address code.

Fluff - the code that was giving me errors was the pasting line, and the pastespecial has resolved the issues i was having, thanks really appreciate it, i knew it would be something simple.
 
Upvote 0
glad you found a fix and thanks for your feedback
(y)
 
Upvote 0
Yongle / fluff

I wonder if you could provide any insight in how i could adapt the above code i previously pasted that works, is still does but i need for another macro an adaption to this coding.

I need the above to loop for every instance of:
Code:
Rowname = S1.Range("E16").Value

that can be found in sheet 2, to be copied and pasted into the new sheet. then once pasted delete the row of data within sheet 2
 
Upvote 0
As this is now a totally different question, please start a new thread.
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,652
Members
448,975
Latest member
sweeberry

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top