Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
882
Hi all, i would like to write a vba command so to run through col. "A" and where find the account's description "Telephones & Postages" should convert it to "Telephones / Postages". In 1st schedule is an extracvt of original data and in 2nd is the expected result. Thanks in advance.


A
1Description
2Marketing expenses
3Subscriptions & Donations
4Telephones & Postages
5Sundry expenses
6Management Fees

<colgroup><col style="mso-width-source:userset;mso-width-alt:1499;width:31pt" width="41"> <col style="mso-width-source:userset;mso-width-alt:10422;width:214pt" width="285"> </colgroup><tbody>
</tbody>






A
1Description
2Marketing expenses
3Subscriptions & Donations
4Telephones / Postages
5Sundry expenses
6Management Fees

<colgroup><col style="mso-width-source:userset;mso-width-alt:1499;width:31pt" width="41"> <col style="mso-width-source:userset;mso-width-alt:10422;width:214pt" width="285"> </colgroup><tbody>
</tbody>
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Looping in VBA is pretty inefficient and should be avoided when possible.
You can do what you want simply by using the built-in "Find/Replace" functionality.
If you want the VBA code for that, simply turn on the Macro Recorder while performing the Find/Replace steps manually.
 
Upvote 0
Ok Joe4, I am sorry that i done a mistake again. I have in col. "A" twice the same description and i wanted to make them unique. This is the reason that the one of those, i should change it to "Telephones / Postages". Apologies once again and many thanks for your interesting to resolve my projects.
Have a nice day
 
Upvote 0
So, are you certain that you will only ever have EXACTLY two instances of this, and you only want to change the second one?
So there will never be three or more records like this?
 
Upvote 0
Hi Joe4. Is duplicate description (just 2 same descriptions) but i want to keep both of them as unique, changing the first one (not second). Below i extended my example and i present it with more details. The first are the original data and in second is the expected result. Thanks once again for your support. Have a nice day



A
1Description
2Selling & Distribution Expenses
3Marketing expenses
4Subscriptions & Donations
5Telephones & Postages
6Sundry expenses
7Management Fees
8
9
Administration Expenses
10Printing & Stationery
11Telephones & Postages
12Electricity

<tbody>
</tbody>



A
1Description
2
Selling & Distribution Expenses
3Marketing expenses
4Subscriptions & Donations
5Telephones / Postages
6Sundry expenses
7Management Fees
8
9
Administration Expenses
10Printing & Stationery
11Telephones & Postages
12Electricity

<colgroup><col style="mso-width-source:userset;mso-width-alt:1499;width:31pt" width="41"> <col style="mso-width-source:userset;mso-width-alt:10422;width:214pt" width="285"> </colgroup><tbody>
</tbody>
 
Upvote 0
So, you just want to replace the first one you find?
Is that correct?
 
Upvote 0
Hi Joe4. Is duplicate description (just 2 same descriptions) but i want to keep both of them as unique, changing the first one (not second).
Give this macro a try...
Code:
[table="width: 500"]
[tr]
	[td]Sub ChangeFirstAmpersandToSlashForTelephonesAndPostages()
  On Error GoTo NoTelephonesPostage
  With Columns("A:A").Find("Telephones & Postages", Range("A1"), xlValues, xlWhole, , xlNext, False, False).Cells
    .Value = Replace(.Value, "&", "/")
  End With
NoTelephonesPostage:
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Thank you so much Rick. It works perfect and is according to what i was required. Thanks also for all your support.
Hv a nice day
 
Upvote 0
.. or even more directly
Code:
Sub ChangeFirstOne()
  On Error Resume Next
  Columns("A").Find(What:="Telephones & Postages", LookAt:=xlWhole, SearchFormat:=False).Value = "Telephones / Postages"
End Sub
 
Upvote 0
Many thanks Peter. The code works perfect too and it appears the expected result. Also thanks for your time spent for my project.
Have a nice day
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,418
Members
449,449
Latest member
Quiet_Nectarine_

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