Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
good day,
I have a simple macro that picks up the file and then deletes some columns: Sub test() Dim sap_file As Variant With Application.FileDialog(msoFileDialogOpen) .AllowMultiSelect = False .Show .Execute End With sap_file = ActiveWorkbook.Name Responce = MsgBox(sap_file, vbOKCancel) If Responce = vbCancel Then Exit Sub End If Workbooks(sap_file).Activate Worksheets("Data").Select Columns("H:Z").Select Selection.Clear Rows("1:1").Select Selection.AutoFilter End Sub on Columns("H:Z").select I get error 400. Strange, if I run this portion of macro in the "sap_file" itself everything works. Do you have any idea what is not right? Thanks Serg |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worked fine for me, although it can be simplified
Sub test() Dim sap_file As Variant With Application.FileDialog(msoFileDialogOpen) .AllowMultiSelect = False .Show .Execute End With sap_file = Activeworkbook.Name Responce = MsgBox(sap_file, vbOKCancel) If Responce = vbCancel Then Exit Sub End If With Worksheets("Data") .Columns("H:Z").Clear .Rows("1:1").AutoFilter End With End Sub -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "SPavlyuk" wrote in message ... good day, I have a simple macro that picks up the file and then deletes some columns: Sub test() Dim sap_file As Variant With Application.FileDialog(msoFileDialogOpen) .AllowMultiSelect = False .Show .Execute End With sap_file = ActiveWorkbook.Name Responce = MsgBox(sap_file, vbOKCancel) If Responce = vbCancel Then Exit Sub End If Workbooks(sap_file).Activate Worksheets("Data").Select Columns("H:Z").Select Selection.Clear Rows("1:1").Select Selection.AutoFilter End Sub on Columns("H:Z").select I get error 400. Strange, if I run this portion of macro in the "sap_file" itself everything works. Do you have any idea what is not right? Thanks Serg |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
better late then never, but thanks.
in my case I had to make the sub public, not private. "SPavlyuk" wrote: good day, I have a simple macro that picks up the file and then deletes some columns: Sub test() Dim sap_file As Variant With Application.FileDialog(msoFileDialogOpen) .AllowMultiSelect = False .Show .Execute End With sap_file = ActiveWorkbook.Name Responce = MsgBox(sap_file, vbOKCancel) If Responce = vbCancel Then Exit Sub End If Workbooks(sap_file).Activate Worksheets("Data").Select Columns("H:Z").Select Selection.Clear Rows("1:1").Select Selection.AutoFilter End Sub on Columns("H:Z").select I get error 400. Strange, if I run this portion of macro in the "sap_file" itself everything works. Do you have any idea what is not right? Thanks Serg |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error when cell A1 is not active and xlInsideVertical border formatthrowing error 1004 | Excel Programming | |||
Error handling error # 1004 Run-time error | Excel Programming | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
Error Handling - On Error GoTo doesn't trap error successfully | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming |