Copy first cell from selected range

methode2404

New Member
Joined
Sep 3, 2018
Messages
30
Hi team,

I have a problem, i can't resolve it.
I want select manuell a part of data (variable) and run macro. Macro should copy the first cell (top-left cell from selection) to Z1, and copy the selected data to sheet2.

How can i do that ?

regards
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
To where on Sheet2?
Do you want to copy it to the upper left corner on Sheet2 (cell A1)?

If so, try this:
Code:
    Sheets("Sheet1").Range(Selection(1, 1), Range("Z1")).Copy Sheets("Sheet2").Range("A1")
 
Upvote 0
Hi Joe4,

Your code works fine, but its not what i want.
Your code copy from A1 to Selected cell ==> to sheet2

what i want is : I have a lot of data in sheet1, i select (for example) A24:C29 and run macro. Macro should copy A24 to (same sheet) cell Z1, and A24:C29 to sheet2 cell A1. but only values. (not formats)
 
Upvote 0
To be honest, your original question was not quite clear, and lacking in detail.
I want select manuell a part of data (variable) and run macro. Macro should copy the first cell (top-left cell from selection) to Z1, and copy the selected data to sheet2.
The fact that you said to "Z1" (which means column Z in row 1), implies that you are copying a single row of data (since you would not be going beyond row 1). Perhaps you meant column Z, but not limited to row 1?

You further description is still quite confusing:
I have a lot of data in sheet1, i select (for example) A24:C29 and run macro. Macro should copy A24 to (same sheet) cell Z1, and A24:C29 to sheet2 cell A1. but only values. (not formats)
A24 to cell Z1 would result in the range A1:Z24 (put your cursor in cell A24 and drag up to cell Z1 - this is the range you would be selecting). Is that really the range you want to copy?

Let's come at it from a different angle.
If you select range A24:C29 on Sheet1, what is the exact range from Sheet1 that you want copied?
 
Upvote 0
i havent a exact range.
This time i select A24:c29 and run macro, another time i select another range for example A49:C55 and run macro.

My macro should copy only the first cell (from selected range) and copy it to exact Z1, (in this example A24)
and paste the whole selected range (A24:C29) to sheet2 cell A1
 
Upvote 0
I know, that you may select a different range each time, I just wanted to see an example to get a better idea of what you are trying to do. It looks like you are trying to copy to two places.
Try this:
Code:
'   Copy value from first cell in selection to cell Z1 on Sheet1
    Sheets("Sheet1").Range("Z1").Value = Selection(1, 1).Value
    
'   Copy values from entire selection to cell A1 on Sheet2
    Selection.Copy
    Sheets("Sheet2").Range("A1").PasteSpecial xlPasteValues
    Application.CutCopyMode = False
 
Upvote 0
No worries! Sometimes a simple example is the best way to clarify things.

I am glad we got it working for you.
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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