Need my Macro to replace words with abbreviations

ahetzel10

New Member
Joined
Dec 21, 2017
Messages
5
Hi all,

I am running a macro to delete and hide some columns of weekly data to quickly create a sheet small enough to print out. I want the macro to automatically replace a couple phrases such as "single family" with "SF", and "new construction" with "NC". How can I incorporate this into my Macro?

Thanks!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi & welcome to the board
How about
Code:
Sub Abbreviate()
   With Columns(1)
      .Replace "single family", "SF", xlPart, , False, , False, False
      .Replace "new construction", "NC", xlPart, , False, , False, False
   End With
End Sub
Changing the column to suit
 
Upvote 0
Just copy the code (without the sub & End sub lines) & paste it into your existing code.
 
Upvote 0
Ok this is what my macro produces for me. Becuase of deleted and hidden columns, "Project type" is column G but is the fifth column from the left.

This is what the end of my attempted code currently looks like with your addition. Not sure what I am doing wrong. Sorry I don't know much about coding...

With Selection.Font
.Name = "Calibri"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontMinor
End With
Range("C1").Select
ActiveCell.FormulaR1C1 = "Permit#"
Columns("H:H").Select
Selection.Copy
Range("H1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "ProjectCity"
Range("H2").Select
With Columns(5)
.Replace "Single Family (Dev.Only)", "SF", xlPart, , False, , False, False
.Replace "new construction", "NC", xlPart, , False, , False, False
End With
End Sub

Permit#PermitDateProjectAddrProjectNameProjectTypeProjectCityCompanyPhoneSizeValueWorkTypeCounty
19/7/2017808 CASTILLA WYSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 115596New ConstructionBarrow
110/23/2017426 RENOWN CTSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 159626New ConstructionBarrow
109/24/20171222 DIANNE DRSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 116530New ConstructionBarrow
1010/12/20172006 MASSEY LNPINNACLE @ YARGO BLDSingle Family (Dev.Only)WINDERVISION HOME CONSTRUCTION, INC.404-569-4217 130546New ConstructionBarrow
119/24/20171220 DIANNE DRSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 115595New ConstructionBarrow
1110/12/20172008 MASSEY LNPINNACLE @ YARGO BLDSingle Family (Dev.Only)WINDERVISION HOME CONSTRUCTION, INC.404-569-4217 127269New ConstructionBarrow
129/24/20171218 DIANNE DRSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 116530New ConstructionBarrow
1210/12/20172010 MASSEY LNPINNACLE @ YARGO BLDSingle Family (Dev.Only)WINDERVISION HOME CONSTRUCTION, INC.404-569-4217 131742New ConstructionBarrow
139/24/20171216 DIANNE DRSUTHERLANDSingle Family (Dev.Only)WINDERLGI HOMES855-441-6300 115595New ConstructionBarrow

<colgroup><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
Hi, I posted some data on here and it said it needed your approval and it disappeared. I can't get the code to work so I was trying to show you whats going on.
 
Upvote 0
Hi, I posted some data on here and it said it needed your approval and it disappeared.
That is just telling you that it needs Moderator approval before you will be able to see it.
I approved it and you can see it now.
 
Upvote 0
Change Columns(5) to Columns(7)
Col G is the 7th column regardless of hidden columns.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,159
Messages
6,123,345
Members
449,097
Latest member
thnirmitha

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