I have the following code that will go through and format my excel spreadsheet:
Code:
'Finds the first empty cell in a column
Range("A1").End(xlDown).Offset(1, 0).Select
'the first few rows of the spreadsheet feature info
'about the filters used from Yotta. Not necessary for
'a database. This will detele these rows
Range(ActiveCell.Row & ":" & ActiveCell.Row).Select
Range("1:1", ActiveCell.Row & ":" & ActiveCell.Row).Delete
Range("A1").Select
'Jumps down to the next row Loops through the row until
'there is an empty cell, clearing the color formats and making the
'font black (automatic)
Do
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
'Finds and replaces spaces with an underscore
ActiveCell.Replace What:=" ", Replacement:="_", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
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
Everything is working just fine in Access, except for the
'Finds and replaces spaces with an underscore
ActiveCell.Replace What:=" ", Replacement:="_", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Instead of only replacing the space in the active cell, the code is changing every space in the spreadsheet with the first active cell replacement. I have run the exact code through Excel vba and had zero problems. Does anyone know why this would be happening throughout my workbook when running it through access?
Thank you!