QuickLearner
New Member
- Joined
- Jun 7, 2011
- Messages
- 3
I have two run-time errors that I'm having an issues with.
1. Run-time error '1004 - Cannot use that command on overlapping selections:
I think this is the code that is giving me a problem:
'(11)Eliminating blank rows
Range("B:B, C:C").Select
X = Selection.SpecialCells(xlCellTypeBlanks).Count
If X <> 0 Then
Range("B:B, C:C").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
End If
2. Run-time error '1004 - too few parameters expected1. This one shows up when one of the fields on the import file can't be found. I was looking for some error trapping code to fix this one.
Sub ImportBaseFile()
'(1) Open UploadEntries Tab
Sheets("UploadEntries").Select
Range("A1").Select
'Import Company(Division C), Cost Center(Loc C), and Expense Amount(Rpt Exp A) from RS_BaseFile on C:Temp
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\temp\RS_BaseFile.xls;Mode=Share Deny Write;Extended Pr" _
, _
"operties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type" _
, _
"=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Dat" _
, _
"abase Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact" _
, "=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"), _
Destination:=Sheets("UploadEntries").Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array( _
"SELECT `RSA$`.`Division C`, `RSA$`.`Loc C`, `RSA$`.`Rpt Exp A`" & Chr(13) & "" & Chr(10) & "FROM `C:\temp\RS_BaseFile`.`RSA$` `RSA$`" & Chr(13) & "" & Chr(10) & "ORDER BY `RSA$`.`Division C`, `RSA$`.`Loc C`, `RSA$`.`Rpt Exp A`" _
)
.Name = "RS_BaseFile_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = "C:\temp\RS_BaseFile.xls"
.Refresh BackgroundQuery:=False
End With
Call RestrictedStock
End Sub
1. Run-time error '1004 - Cannot use that command on overlapping selections:
I think this is the code that is giving me a problem:
'(11)Eliminating blank rows
Range("B:B, C:C").Select
X = Selection.SpecialCells(xlCellTypeBlanks).Count
If X <> 0 Then
Range("B:B, C:C").Select
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
End If
2. Run-time error '1004 - too few parameters expected1. This one shows up when one of the fields on the import file can't be found. I was looking for some error trapping code to fix this one.
Sub ImportBaseFile()
'(1) Open UploadEntries Tab
Sheets("UploadEntries").Select
Range("A1").Select
'Import Company(Division C), Cost Center(Loc C), and Expense Amount(Rpt Exp A) from RS_BaseFile on C:Temp
With ActiveSheet.QueryTables.Add(Connection:=Array( _
"OLEDB;Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\temp\RS_BaseFile.xls;Mode=Share Deny Write;Extended Pr" _
, _
"operties=""HDR=YES;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type" _
, _
"=35;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Dat" _
, _
"abase Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact" _
, "=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False"), _
Destination:=Sheets("UploadEntries").Range("A1"))
.CommandType = xlCmdTable
.CommandText = Array( _
"SELECT `RSA$`.`Division C`, `RSA$`.`Loc C`, `RSA$`.`Rpt Exp A`" & Chr(13) & "" & Chr(10) & "FROM `C:\temp\RS_BaseFile`.`RSA$` `RSA$`" & Chr(13) & "" & Chr(10) & "ORDER BY `RSA$`.`Division C`, `RSA$`.`Loc C`, `RSA$`.`Rpt Exp A`" _
)
.Name = "RS_BaseFile_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = "C:\temp\RS_BaseFile.xls"
.Refresh BackgroundQuery:=False
End With
Call RestrictedStock
End Sub