VBA get the cell value in a cell that is on the same row.

decadence

Well-known Member
Joined
Oct 9, 2015
Messages
525
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
Platform
  1. Windows
Hi, Is it possible to copy or get the cell value from a set range of cells which is a variable to a static range of cells that will never change but on the same row.

I am using this for my range variable but Columns("AA:AA") will be the static range
Code:
        Set Rng = Rng.Resize(Cells(Rows.Count, Rng.Column).End(xlUp).Row)


Example 1:

Form this
[TABLE="class: grid, width: 150"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Cell Value 1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Cell Value 2
[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

To this
[TABLE="class: grid, width: 150"]
<tbody>[TR]
[TD][/TD]
[TD]AA
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Cell Value 1
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Cell Value 2
[/TD]
[/TR]
</tbody>[/TABLE]

Example 2:

From this
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Cell Value 1
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Cell Value 2
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Cell Value 3
[/TD]
[/TR]
</tbody>[/TABLE]

To this

[TABLE="class: grid, width: 150"]
<tbody>[TR]
[TD][/TD]
[TD]AA
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]Cell Value 1
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]Cell Value 2
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]Cell Value 3
[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
How about
Code:
Set rng = rng.Resize(Cells(Rows.Count, rng.Column).End(xlUp).Row)
rng.Copy Range("AA" & rng.Row)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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