alexfwalker81
Member
- Local time
- Yesterday, 18:46
- Joined
- Feb 26, 2016
- Messages
- 107
I have two great bits of code, which work well in Excel and Access.
This works well in Excel to identify gaps and close them up for me. Thank you @Gasman
This works well to identify non Ascii in Access. Thank you to a colleague of mine.
Is there a way that I can take the existing code which identifies gaps in Excel, and insert the actions of the Access code, so that I have a subroutine in Excel which loops through all of my data and removes all the non Ascii characters? I've tried what I thought was obvious and failed!
This works well in Excel to identify gaps and close them up for me. Thank you @Gasman
Code:
Sub Tidy_Address()
Dim iLoop1 As Integer, iLoop2 As Integer, iLastRow As Integer
iLastRow = ActiveSheet.UsedRange.Rows.Count
Range("B1").Select
While ActiveCell.Row <= iLastRow
iLoop = 1
While iLoop < 4
' MsgBox (ActiveCell.Offset(0, iLoop).Value)
If IsEmpty(ActiveCell.Offset(0, iLoop)) Then
For iLoop2 = iLoop To 3
If Not IsEmpty(ActiveCell.Offset(0, iLoop2 + 1).Value) Then
ActiveCell.Offset(0, iLoop).Value = ActiveCell.Offset(0, iLoop2 + 1).Value
ActiveCell.Offset(0, iLoop2 + 1).Value = ""
Exit For
End If
Next iLoop2
End If
iLoop = iLoop + 1
Wend
ActiveCell.Offset(1, 0).Activate
Wend
Range("A1").Select
End Sub
This works well to identify non Ascii in Access. Thank you to a colleague of mine.
Code:
Public Function RemoveNonASCII(str As String) As String
Dim i As Integer
For i = 1 To Len(str)
If AscW(Mid(str, i, 1)) < 127 Then
RemoveNonASCII = RemoveNonASCII & Mid(str, i, 1)
End If
Next i
End Function
Is there a way that I can take the existing code which identifies gaps in Excel, and insert the actions of the Access code, so that I have a subroutine in Excel which loops through all of my data and removes all the non Ascii characters? I've tried what I thought was obvious and failed!