get value from other sheet in active sheet

fredemel

New Member
Joined
Oct 17, 2012
Messages
4
I would like to get a value in "this" openend Worksheet from an other sheet

This is my formula IN "Sheet2":
Application.Cells(ActiveCell.Row, "K").Value = ActiveWorkbook.Worksheets("Sheet1").Application.Cells(ActiveCell.Row, "C").Value

What's wrong?

Please your help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
If you mean your code is in the Sheet2 module and you want to get the value from the "same row" in sheet 1 then it would normally look more like this.
VBA Code:
Cells(ActiveCell.Row, "K").Value = Worksheets("Sheet1").Cells(ActiveCell.Row, "C").Value
 
Upvote 0
Do you have a sheet with the tab name of Sheet1 ?
Are both sheets in the same workbook ?
Is that the same workbook that the code is in ?
Is the code in the module of Sheet2 ?
 
Upvote 0
@ Alex,

I've tryed this, but when you use a variable like: x = Worksheets("Sheet1").Cells(ActiveCell.Row, "C").Value
and you chek it with msgbox a then this is empty.... :-((
But when you first go to sheet 1 and then use the macro: x = Worksheets("Sheet1").Cells(ActiveCell.Row, "C").Value
and then go back to sheet2 and use the macro: Worksheets("Sheet1").Cells(ActiveCell.Row, "K").Value = x it works....
BUT,..... I would like to use the code within sheet2. Is that possible..........?

responding:
Do you have a sheet with the tab name of Sheet1 ? sheet-names are sheet1 and sheet2
Are both sheets in the same workbook ? Yes
Is that the same workbook that the code is in ? In a separate module
Is the code in the module of Sheet2 ? '' '' ''
 
Upvote 0
You need to show all your code and describe what you are trying to achieve preferably with images.
If you have the code in a separate module then there is no default sheet and "any" code that doesn't specify the sheet will assume the ActiveSheet.
You are using ActiveCell and this will only ever be the currently activecell on the ActiveSheet.

VBA Code:
Application.Cells(ActiveCell.Row, "K").Value
Is not fully qualified and as such relies on the ActiveSheet

VBA Code:
ActiveWorkbook.Worksheets("Sheet1").Application.Cells(ActiveCell.Row, "C").Value
Although it mentions Sheet1 the Cells part uses ActiveCell which again will that the ActiveCell of the currently ActiveSheet
 
Upvote 0
Alex,

thanks for the reply. And I understand... So when I give a variable a value I first need to "move" to the right sheet.
And "move" to the right sheet/activecell or so..... BUT..........
Is there an other way.....? Just "pick" a value from an other sheet, without "moving" first..... AND not using a variable...?
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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