VBA insert column with two workbooks open

Joined
Aug 29, 2012
Messages
2
Reaction score
0
Hi,

I'm writing a macro that lets the user select a file with product codes that need to be correctly formatted. Then the user can select the worksheet in the selected workbook. The workbook is opened, and I want to add a column. The code then runs through the opened file and compares to a worksheet in the file that the macro is saved in to get the correct format. The correctly formatted code will go into a new column.

My code to insert a column is bugging and I don't understand why. Thanks for your help!

Here is the code that I think is pertinent:

...
Set objFSO = CreateObject("scripting.filesystemobject")
fichEtRep = Application.GetOpenFilename(fileFilter:="XLS Files (*.xls),*.xls", Title:="Sélection le fichier avec les codes articles à formatter", Buttontext:="OK")
fichAOuvrir.Text = fichEtRep
...

...
Workbooks(fichAOuvrir).Worksheets(cboWorksheets.Value).Range(A).EntireColumn.Insert
 
Joined
Aug 29, 2012
Messages
2
Reaction score
0
Ok, so it seems that its more than just inserting - but it must be an error in the way I'm accessing the worksheet. I tried inserting a row manually to get on with my tests, and this line also bugs:

article = Workbooks(fichAOuvrir).Worksheets(cboWorksheets.Value).Cells(rowFormat, colFormat)

fichAOuvrir has the complete file name (with directory)
cboWorksheets is a combo with the worksheets in the file, the user must select a worksheet from the list
rowFormat and ColFormat are both initialized to 1 for the moment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top