Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Relative cells in previous sheet

Hello, could really use some help with something. I am trying to
write an Excel macro that will do the following:
1. Use whatever cell I currently have selected on any given sheet as a
relative cell.
2. Go back one sheet (using PreviousSheet) and copy the data from that
same relative cell.
3. Paste that data into the relative cell on the given sheet I was on.

I have 13 sheets and I want to copy the data from a specific cell on
one sheet to the same cell on the next sheet. The sheets and cells
have to be non-specific in the macro to allow me to run the macro on
any of my 13 sheets and any of the cells on that sheet.

If I record the macro as I do it I end up with the following in VBA:
Range("C12).Select
Sheets("Sheet 3").Select
Range("C12").Select
Selection.Copy
Sheets("Sheet 4").Select
Range("C12").Select
Selection.PasteSpecial Paste:=x1PasteValues, Operation:=x1None,
SkipBlanks _
:=False, Transpose:=False

Obviously, from my explanation, I need to replace the "C12" reference
so the macro just runs from whatever cell I have selected, and the
"Sheet 3" and "Sheet 4" refrences have to be replaced to allow the
macro to run from whatever sheet I'm currently on and go back one
sheet to copy the data. I've been using PreviousSheet which I set up
awhile ago and has worked great for my other macros in this
spreadsheet. I just can't get this one to work. Any help anyone can
offer would be greatly appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Relative cells in previous sheet

Perhaps

Sub test()
Dim lngLast As Long

lngLast = Application.Max(1, ActiveSheet.Index - 1)
With ActiveCell
.Value = Sheets(lngLast).Range(.Address)
End With

End Sub


" wrote:

Hello, could really use some help with something. I am trying to
write an Excel macro that will do the following:
1. Use whatever cell I currently have selected on any given sheet as a
relative cell.
2. Go back one sheet (using PreviousSheet) and copy the data from that
same relative cell.
3. Paste that data into the relative cell on the given sheet I was on.

I have 13 sheets and I want to copy the data from a specific cell on
one sheet to the same cell on the next sheet. The sheets and cells
have to be non-specific in the macro to allow me to run the macro on
any of my 13 sheets and any of the cells on that sheet.

If I record the macro as I do it I end up with the following in VBA:
Range("C12).Select
Sheets("Sheet 3").Select
Range("C12").Select
Selection.Copy
Sheets("Sheet 4").Select
Range("C12").Select
Selection.PasteSpecial Paste:=x1PasteValues, Operation:=x1None,
SkipBlanks _
:=False, Transpose:=False

Obviously, from my explanation, I need to replace the "C12" reference
so the macro just runs from whatever cell I have selected, and the
"Sheet 3" and "Sheet 4" refrences have to be replaced to allow the
macro to run from whatever sheet I'm currently on and go back one
sheet to copy the data. I've been using PreviousSheet which I set up
awhile ago and has worked great for my other macros in this
spreadsheet. I just can't get this one to work. Any help anyone can
offer would be greatly appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Relative cells in previous sheet

On Apr 30, 4:44 pm, JMB wrote:
Perhaps

Sub test()
Dim lngLast As Long

lngLast = Application.Max(1, ActiveSheet.Index - 1)
With ActiveCell
.Value = Sheets(lngLast).Range(.Address)
End With

End Sub



" wrote:
Hello, could really use some help with something. I am trying to
write anExcelmacro that will do the following:
1. Use whatevercellI currently have selected on any given sheet as a
relativecell.
2. Go back one sheet (usingPreviousSheet) and copy the data from that
samerelativecell.
3. Paste that data into therelativecellon the given sheet I was on.


I have 13 sheets and I want to copy the data from a specificcellon
one sheet to the samecellon the next sheet. The sheets and cells
have to be non-specific in the macro to allow me to run the macro on
any of my 13 sheets and any of the cells on that sheet.


If I record the macro as I do it I end up with the following in VBA:
Range("C12).Select
Sheets("Sheet 3").Select
Range("C12").Select
Selection.Copy
Sheets("Sheet 4").Select
Range("C12").Select
Selection.PasteSpecial Paste:=x1PasteValues, Operation:=x1None,
SkipBlanks _
:=False, Transpose:=False


Obviously, from my explanation, I need to replace the "C12" reference
so the macro just runs from whatevercellI have selected, and the
"Sheet 3" and "Sheet 4" refrences have to be replaced to allow the
macro to run from whatever sheet I'm currently on and go back one
sheet to copy the data. I've been usingPreviousSheetwhich I set up
awhile ago and has worked great for my other macros in this
spreadsheet. I just can't get this one to work. Any help anyone can
offer would be greatly appreciated.- Hide quoted text -


- Show quoted text -


That was perfect! Thank you very much! I have no idea how that works
or what those commands mean - but it does exactly what I needed.
Thanks again.

  #4   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Relative cells in previous sheet

you're welcome.

" wrote:

On Apr 30, 4:44 pm, JMB wrote:
Perhaps

Sub test()
Dim lngLast As Long

lngLast = Application.Max(1, ActiveSheet.Index - 1)
With ActiveCell
.Value = Sheets(lngLast).Range(.Address)
End With

End Sub



" wrote:
Hello, could really use some help with something. I am trying to
write anExcelmacro that will do the following:
1. Use whatevercellI currently have selected on any given sheet as a
relativecell.
2. Go back one sheet (usingPreviousSheet) and copy the data from that
samerelativecell.
3. Paste that data into therelativecellon the given sheet I was on.


I have 13 sheets and I want to copy the data from a specificcellon
one sheet to the samecellon the next sheet. The sheets and cells
have to be non-specific in the macro to allow me to run the macro on
any of my 13 sheets and any of the cells on that sheet.


If I record the macro as I do it I end up with the following in VBA:
Range("C12).Select
Sheets("Sheet 3").Select
Range("C12").Select
Selection.Copy
Sheets("Sheet 4").Select
Range("C12").Select
Selection.PasteSpecial Paste:=x1PasteValues, Operation:=x1None,
SkipBlanks _
:=False, Transpose:=False


Obviously, from my explanation, I need to replace the "C12" reference
so the macro just runs from whatevercellI have selected, and the
"Sheet 3" and "Sheet 4" refrences have to be replaced to allow the
macro to run from whatever sheet I'm currently on and go back one
sheet to copy the data. I've been usingPreviousSheetwhich I set up
awhile ago and has worked great for my other macros in this
spreadsheet. I just can't get this one to work. Any help anyone can
offer would be greatly appreciated.- Hide quoted text -


- Show quoted text -


That was perfect! Thank you very much! I have no idea how that works
or what those commands mean - but it does exactly what I needed.
Thanks again.


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
Linking cells from the previous sheet Ed Davis[_2_] Excel Discussion (Misc queries) 10 October 7th 09 01:38 AM
Protect Sheet: clicking in cells removes all previous text Kristin Excel Discussion (Misc queries) 1 October 25th 06 10:18 PM
Protect Sheet: clicking in cells removes all previous text Kristin Excel Discussion (Misc queries) 3 September 5th 06 07:30 PM
Relative reference to a cell on a previous sheet [email protected] Excel Discussion (Misc queries) 1 July 17th 06 07:27 PM
How do I make a 5th sheet to total cells from previous sheets in . Chuck-Baby Excel Worksheet Functions 2 March 3rd 05 01:22 AM


All times are GMT +1. The time now is 01:13 AM.

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

About Us

"It's about Microsoft Excel"