I have an access database that is importing an excel spreadsheet. This spreadsheet is given every week from an external reporting service. I have some formatting that needs to be done before I can import the sheet through access. I need to do this through access, and have a macro set up to do just this. Everything works great; I just have one problem. My find and replace code works perfectly in excel but causes me errors in access. Specifically, the code is:
In Excel, only the first row is looped through, and only the currently active cell is replaced. When I run the same code through access, for some reason the first cell triggers the entire sheet and every cell has spaces replaced, instead of only the range specified in my loop. Does anyone know of a way around this?
I've been told this isn't the best way to do this, and that I should be doing this specifically in excel, but that isn't feasible given my situation and I need to run it through access.
Thank you for any help you may be able to provide!!
Lorelai
Code:
Do
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
[B]'Finds and replaces spaces with an underscore[/B]
[B]ActiveCell.Replace What:=" ", Replacement:="_"[/B]
ActiveCell.Offset(0, 1).Select
Loop Until IsEmpty(ActiveCell)
'Deletes the last row of data
Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Select
Selection.Delete Shift:=xlUp
I've been told this isn't the best way to do this, and that I should be doing this specifically in excel, but that isn't feasible given my situation and I need to run it through access.
Thank you for any help you may be able to provide!!
Lorelai