Generic code for selecting the next column from a specific range - VBA

KNKN9

Board Regular
Joined
Mar 27, 2017
Messages
92
Hi,

I have a data set similar to below

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]x[/TD]
[TD]x[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]y[/TD]
[TD]y[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I am trying to find a code that allows me to selecting the next empty column. This can't use the Range("C12") as every week data gets updated and a new column will be filled with data.

Hope someone can help.

Thanks
Naomie
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You could try:

Code:
lr = Range("C" & Rows.Count).End(xlUp).Row

then use the variable like this:

Code:
Set rng = Range("C" & lr)

as an example.
 
Last edited:
Upvote 0
That finds the next empty 'ROW'
We want the next empty 'Column'

Try

lc = Cells(12, Columns.Count).End(xlToLeft).Column + 1

Then you can use it like
Cells(12,lc)
 
Upvote 0
Thank you very much Jon,
This code works exactly how I want it to.
Much appreciated :)

Naomie.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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