How do i copy values from the previous sheet?

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
i have the following
Code:
ActiveCell.Offset(0, 0).Range("A1:C500").Value2 = ActiveCell.Offset(0, 0).Range("A1:C500").Value2

how do i modify this to copy values from previous sheet instead of current into same range

if it helps, the sheets are labelled as weekly dates (dd-mm)
26-11
03-12
10-12
17-12
24-12

the tabs are in the appropriate order though so i dont think names matter

appreciate any help
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Maybe (Change address references as required)
Code:
ActiveSheet.Range("A1:C4").Value = Sheets(ActiveSheet.Index - 1).Range("A1:C4").Value
 
Upvote 0
The above did nothing

i tried like so:
Code:
ActiveCell.Offset(0, 0).Range("A1:C500").Value2 = ActiveCell.Offset(0, 0).Sheets(ActiveSheet.Index - 1).Range("A1:C500").Value2

and i get object doesnt support this property or method.
 
Upvote 0
Here ya go- put this in a module and then use "=PrevSheet('Cell from Previous Page) in a formula.
Code:
Function PrevSheet(RCell As Range)
    Dim xIndex As Long
    Application.Volatile
    xIndex = RCell.Worksheet.Index
    If xIndex > 1 Then
        PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
    End If
End Function
 
Upvote 0
Which cells from the previous sheet do you want to copy/paste?
 
Upvote 0
This will probably do what you have in mind.

Code:
Dim a As String
a = ActiveCell.Offset(0, 0).Range("A1:C500").Address
ActiveSheet.Range(a).Value2 = Sheets(ActiveSheet.Index - 1).Range(a).Value2
 
Upvote 0
Did you try my function piece? I know mine works- I have it working in an active workbook now. It will only reference the previous sheet to the activesheet.
 
Upvote 0
@sassriverrat
Thanks, the function works great and definitely one I will save for future stuff :)
@jolivanes not tried your code yet, but what I wanted to copy was the 3 columns from active cell

I don't know where the A1:C500 comes from? Probably because of relative referencing. It's what come from the macro recorder.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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