Select first cell in offset column?

Joined
Jan 30, 2022
Messages
30
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have a loop that runs through to add a new column after the columns in the array. I'm just struggling to find the right function to select the first cell in the newly-created blank column, recognising that the range is a column and not a cell. I have tried offset and offset+cell but obviously am getting errors.

Current code is:

VBA Code:
For Each col In Array("H", "K")

        Set Rng = ActiveSheet.Columns(col)

        With Rng

            .Offset(, 1).EntireColumn.Insert

            .TextToColumns Destination:=Rng.Offset(, 1), DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, FieldInfo:=Array(1, 3), TrailingMinusNumbers:=True

            .EntireColumn.DELETE

        End With    

Next

This is being adapted from an in-place text to columns to force-recognise dates in AU format - this has stopped working and I would rather add a new column, TTC the date format and delete the original column rather than guess whether this code will work in one workbook but not another.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I presume you are talking about the Destination argument for TextToColumns. Change the assigned expression from the one you have to this one...

Rng.Offset(, 1).EntireColumn.Cells(1)

Note: I left the Rng in the expression mainly so the "dot" in front of Offset would not get "lost", but you can eliminate the Rng because your code line is running inside a With block where Rng is its object.
 
Upvote 0
Solution
I presume you are talking about the Destination argument for TextToColumns. Change the assigned expression from the one you have to this one...

Rng.Offset(, 1).EntireColumn.Cells(1)

Note: I left the Rng in the expression mainly so the "dot" in front of Offset would not get "lost", but you can eliminate the Rng because your code line is running inside a With block where Rng is its object.
Cheers mate, I knew it would be something that simple, I missed the EntireColumn between the two functions. Much appreciated!
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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