Insert a new column from selected cell

waxb18

Board Regular
Joined
May 31, 2011
Messages
179
Basically i have an empty column and want to insert another one.
There is data on either side of the empty column.

I then need to input data from another spreadsheet (this i know how to do in VBA), however as i will be doing this daily the reference i input for these cells will change hence i will need a generic. I was thinking of using an End(xlright) to get to the empty cell then use a offset(,-1) to get to the cell i want to select.

What do you guys think?
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
This is the start of my code to select the empty cell in Column DL

Range("B3").End(xlToRight).Offset(, 1).Select
 
Upvote 0
yet again VoG you provide invaluable help...

Another quick one... i need to open the most recently produced file from a directory any ideas?
 
Upvote 0
Try this - change the part in red to suit

Rich (BB code):
Sub LastModifiedFile()
Dim dirName As String, fName As String, fileTime As Date, fileName As String, latestFile As String
dirName = "C:\My Documents\"
fName = Dir(dirName & "*.*")
latestFile = fName
fileTime = FileDateTime(dirName & fName)
While fName <> ""
    If FileDateTime(dirName & fName) > fileTime Then
        latestFile = fName
        fileTime = FileDateTime(dirName & fName)
    End If
    fName = Dir()
Wend
If latestFile = "" Then
    MsgBox "There are no files in the directory"
Else
    Workbooks.Open "C:\My Documents\" & latestFile
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

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