PDA

View Full Version : Solved: New procedure at end of code?



jdgalaway
03-06-2013, 10:24 AM
First, I am pretty new to VBA so this may be stupid easy, but I hope someone can help.

We have a macro and the person who wrote the code no longer works for us. I'm trying to use my limited VBA knowledge to edit it.

The macro imports data into excel from a folder containing several other spreadsheets.

After the code is done importing the data, I want to simply insert a column. I used the following code, but it just isn't working. If someone could please help me out, I would appreciate it.

Public Static Sub insertColumn(ByRef Sheets As Sheets)

Worksheets("Summary").Range("AJ1").EntireColumn.Insert


End Sub

Zack Barresse
03-06-2013, 10:31 AM
Hi there, welcome to the board!

While the code you posted should work, we can't be sure. When working with multiple workbooks, it's generally a good idea to specifically reference that workbook. You have the worksheet referenced explicitly, just not the book. Is there any way you could post the entire code? That would give us a much better idea of what you're working with.

jdgalaway
03-06-2013, 10:45 AM
I appreciate it, but I solved my problem. I relocated the code within the main procedure. Might not make sense, but as I said, I'm pretty new to all this.

Zack Barresse
03-06-2013, 10:46 AM
Great! Can you mark your thread as Solved? (Look at the Thread Tools button.)