VBA Offset copy and pasting

mvervair

New Member
Joined
Aug 3, 2016
Messages
27
Ok, I'm back at it with another copy and paste question. In this sub I have a cell I click on(customer name) and it begins copy and pasting information from one sheet to another. However I'm not even able to compile this code. I have a feeling the ActiveCell is causing the problem. Any ideas?

Code:
Dim jobTracking As Worksheet
Dim resApp As Worksheet

Set resApp = Worksheets("residential_applications")
Set jobTracking = Worksheets("residential_job_tracking")

    jobTracking.Range("C1").End(xlDown).Offset(0, 1).Value = resApp.ActiveCell.Value
    'acct
    jobTracking.Range("C1").End(xlDown).Offset(-1, 1).Value = resApp.ActiveCell.Offset(-1, 0).Value
    'address
    jobTracking.Range("C1").End(xlDown).Offset(1, 1).Value = resApp.ActiveCell.Offset(3, 0).Value
    'city
    jobTracking.Range("C1").End(xlDown).Offset(2, 1).Value = resApp.ActiveCell.Offset(4, 0).Value
    'zip
    jobTracking.Range("C1").End(xlDown).Offset(3, 1).Value = resApp.ActiveCell.Offset(5, 0).Value
    'app received date
    jobTracking.Range("C1").End(xlDown).Offset(8, 1).Value = resApp.ActiveCell.Offset(-2, 0).Value
    'phone
    jobTracking.Range("C1").End(xlDown).Offset(12, 1).Value = resApp.ActiveCell.Offset(2, 0).Value
    'em
    jobTracking.Range("C1").End(xlDown).Offset(13, 1).Value = resApp.ActiveCell.Offset(1, 0).Value
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
What is the compile error(s) you get? Wiil you run this code while the sheet resApp is the active sheet?
 
Last edited:
Upvote 0
It says method or data member not found, then highlights the first ActiveCell in the code.

Whether I run it in the resApp or jobTracking sheets it throws the same error.
 
Last edited:
Upvote 0
It says method or data member not found, then highlights the first ActiveCell in the code.

Whether I run it in the resApp or jobTracking sheets it throws the same error.
Try running it from the resApp sheet after you remove "resApp." from the right side of the "=" sign on every line. The active cell, by definition, is on the active sheet (only) and so neither needs nor wants a sheet qualifier.

Also, be sure you have something below C1 on the jobTracking sheet or End(xlDown) will take you to the last cell at the bottom of the sheet and your attempts to offset that by +ve row amounts will take you off the sheet and generate a run time error.
 
Upvote 0
Yes, since the end(xlDown) is in every line it was starting an additional row after it created the first new row so I had to change some things. Also I got my offset values backwards in my first post. Here's the final version that is working:

Code:
    jobTracking.Range("C1").End(xlDown).Offset(1, 0).Value = ActiveCell.Value
    'acct
    jobTracking.Range("C1").End(xlDown).Offset(0, -1).Value = ActiveCell.Offset(0, -1).Value
    'address
    jobTracking.Range("C1").End(xlDown).Offset(0, 1).Value = ActiveCell.Offset(0, 3).Value
    'city
    jobTracking.Range("C1").End(xlDown).Offset(0, 2).Value = ActiveCell.Offset(0, 4).Value
    'zip
    jobTracking.Range("C1").End(xlDown).Offset(0, 3).Value = ActiveCell.Offset(0, 5).Value
    'app received date
    jobTracking.Range("C1").End(xlDown).Offset(0, 8).Value = ActiveCell.Offset(0, -2).Value
    'phone
    jobTracking.Range("C1").End(xlDown).Offset(0, 12).Value = ActiveCell.Offset(0, 2).Value
    'em
    jobTracking.Range("C1").End(xlDown).Offset(0, 13).Value = ActiveCell.Offset(0, 1).Value
 
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,215
Members
449,215
Latest member
texmansru47

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