Need help with a macro

JGNWA

New Member
Joined
Aug 20, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Need help with a macro to evaluate each row of text. If text starts with any date and time to delete both the date and time and leave remaining text. If row text begins with "AC- " delete "AC- " from the text and leave the remaining text.
Thanks for the help.


LOAN PAYMENT TO CL-0000000241011050
12/27 20:40 Etsy.com - AnywayS Brooklyn NY CKCD DEBIT 8040
12/29 16:18 LOWE'S POS DEBIT 8040
AC-CAPITAL ONE -CRCARDPMT
12/30 08:13 APPLE.COM/BILL 866-712-7753 CA CKCD DEBIT 8040
12/30 12:43 HARP'S FOOD ST POS DEBIT 6507
12/30 12:58 WALGREENS 4015 POS DEBIT 6507
AC-APPLECARD GSBANK-PAYMENT
01/01 02:04 discovery+ 0123456789 TN CKCD DEBIT 6507
01/01 21:03 APPLE.COM/BILL 866-712-7753 CA CKCD DEBIT 8040
01/02 09:46 APPLE.COM/BILL 866-712-7753 CA CKCD DEBIT 8040
01/03 12:05 COLLIER DRUG FAR POS DEBIT 6507
01/03 12:21 WAL-MART Wal-Mar POS DEBIT 6507
12/30 02:01 MCDONALD EYE A CKCD DEBIT 8040
12/31 09:04 PANDA EXPRESSR CKCD DEBIT 6507
12/31 21:36 MCALISTER'S CKCD DEBIT 6507
AC-BENEFIT PAYMENTS-DEPOSIT
AC-ELECTRIC -PPDDRAFT
AC- ELECTRIC -PPDDRAFT
AC-CITY UTILITYPMT
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Welcome to the forum, You haven't specified where the column of data is, so I assumed in range A1 to A20, but just change the reference to A1:A20 in the two places in the code to your needs:
VBA Code:
Sub test2()
inarr = Range("a1:A20")
For i = 1 To UBound(inarr, 1)
If Mid(inarr(i, 1), 3, 1) = "/" And Mid(inarr(i, 1), 9, 1) = ":" Then
inarr(i, 1) = Mid(inarr(i, 1), 13)
Else
 If Left(inarr(i, 1), 3) = "AC-" Then
  inarr(i, 1) = Mid(inarr(i, 1), 4)
 End If
End If
Next i

Range("a1:A20") = inarr
End Sub
 
Upvote 0
Solution
maybe this will not help at all and I know less when it comes to Macro.
Have you tried using SUBSTITUTE and RIGHT or LEFT formulas?

good luck
 
Upvote 0
Welcome to the forum, You haven't specified where the column of data is, so I assumed in range A1 to A20, but just change the reference to A1:A20 in the two places in the code to your needs:
VBA Code:
Sub test2()
inarr = Range("a1:A20")
For i = 1 To UBound(inarr, 1)
If Mid(inarr(i, 1), 3, 1) = "/" And Mid(inarr(i, 1), 9, 1) = ":" Then
inarr(i, 1) = Mid(inarr(i, 1), 13)
Else
 If Left(inarr(i, 1), 3) = "AC-" Then
  inarr(i, 1) = Mid(inarr(i, 1), 4)
 End If
End If
Next i

Range("a1:A20") = inarr
End Sub
Thanks so much!!!
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,069
Members
449,092
Latest member
ipruravindra

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top