captainxcel
New Member
- Joined
- Jul 28, 2017
- Messages
- 35
- Office Version
- 2016
- Platform
- Windows
Hello,
I have a table (list object) called balances_table which starts in cell A1 and is the only data on on a particular worksheet. I paste data into the table from a downloaded csv file as below (a few sample rows included). I'd like to write a macro to remove the strings "Account Number: " and "-" from the Account column so that the account column has only numbers like 11112222 and 33334444. The code I wrote (see below table) is not working exactly as planned. It does clean up the Account column exactly as I wanted, but it is also removing negative signs from the Balance column (which is in column C), which I do not want to happen. What am I doing wrong?
Thanks!
Sub clean_up_acct_col()
Columns("A:A").Replace What:="-", Replacement:="", _
LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
Columns("A:A").Replace What:="Account Number: ", Replacement:="", _
LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
End Sub
I have a table (list object) called balances_table which starts in cell A1 and is the only data on on a particular worksheet. I paste data into the table from a downloaded csv file as below (a few sample rows included). I'd like to write a macro to remove the strings "Account Number: " and "-" from the Account column so that the account column has only numbers like 11112222 and 33334444. The code I wrote (see below table) is not working exactly as planned. It does clean up the Account column exactly as I wanted, but it is also removing negative signs from the Balance column (which is in column C), which I do not want to happen. What am I doing wrong?
Thanks!
Account | Name | Balance |
Account Number: 1111-2222 | Smith Foods | -125.73 |
Account Number: 3333-4444 | Johnson Supermarkets | 1250.99 |
Sub clean_up_acct_col()
Columns("A:A").Replace What:="-", Replacement:="", _
LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
Columns("A:A").Replace What:="Account Number: ", Replacement:="", _
LookAt:=xlPart, SearchFormat:=False, ReplaceFormat:=False
End Sub