I need to write a function in Access vba to delete entire column or columns and shift lef in Excel. After delete the column(s), it will save the change. This function can be reused so it will allow me to pass parameters - Excel file name, sheet name, and column number(column ranges).
I tried but my code does not work. Any help will be greatly appreciated ! Thank you very much!
I use a command button to invoke the function but
I got "Run-time error '1004'; Application-defined or object-defined error" on the line oSheet.Range(cellcolumn).EntireColumn.Delete xlShiftToLeft
Private Sub cmd1_Click()
Dim bookname As String
bookname = "c:\file1.xls"
This pre-supposes that 'cellcolumn' is a valid coulmn reference string
ie "F:F" or "F" or "C:F" etc
It could also be an integer for a single column.
Thank you so much again!!
I changed the code in the command button to either
Dim cellcolumn As String
cellcolumn = "H"
Dim cellcolumn As Integer
cellcolumn = 8
but I still get the same error on the same line.
It seems to me that it may not be the input parameters, but the reference of excel sheet????
By the way, I have very limited knowledge about excel. I don't know about F:F or C:F. Is it supposed to have a number to reference the row number when we reference a cell like A2 ?
Would you please teach me more about that and maybe use some examples?