Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2014, 01:11 PM
shilabrow shilabrow is offline Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Windows Vista Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Office 2007
Advanced Beginner
Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks
 
Join Date: Apr 2014
Posts: 45
shilabrow is on a distinguished road
Default Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks

Please help me with the following code. I dont know what am doing wrong. I recorded the following and when I ran it, it was good but I notice that when I rerun it - it messes up the data. I am thinking I should put "if no replacement then dont rerun in the code. Or could it be the Sorting part or do I need the loop. I am not too good with Programming element. All help in helping me straighten out the code to run perfectly all the time regardless of how many times ran would be appreciated. Thanks much

The code below is to;
Remove the * from the Data, Custom Sort, Replace Actions with right wordings, to refresh all pivot table in my worksheets and autofit all cells.


' Here am trying to remove the * from the data but when I just want to replace * it wipes out all the data so did it as shown below. Any help to streamline this will be helpful.

Sub Code ()
Sheets("DATA").Select
Columns("F:F").Select
Selection.Replace What:="*Apple", Replacement:="Apple", LookAt _
:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
Selection.Replace What:="*Banana", Replacement:= _
"Banana", LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase _
:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="*Discount", Replacement:="Discount", LookAt _
:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
Selection.Replace What:="*Fruits", Replacement:= _
"Fruits", LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:= _
False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="*Papaya", Replacement:="Papaya" _
, LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, _
SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="*Tomatoes", Replacement:="Tomatoes", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="*Sprite", Replacement:= _
"Sprite", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="*Serious", Replacement:= _
"Serious", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

'To Custom Sort the Subcateg in the right order needed in the Reports

ActiveWorkbook.Worksheets("DATA").Sort.SortFields. Clear
ActiveWorkbook.Worksheets("DATA").Sort.SortFields. Add Key:=Range("F2:F451"), _
SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:= _
"Apple,Discount,Banana,Tomatoes,Papaya,fruits,Spri te,Serious" _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("DATA").Sort
.SetRange Range("F1:F451")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

'To find and replace Actions to Standard Wording for Report.
Columns("N:N").Select
Selection.Replace What:="Coach", Replacement:= _
"Coaches", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="Coached", Replacement:= _
"Coaches", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="Ignore", Replacement:= _
"Participate", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Selection.Replace What:="Ignored", Replacement:= _
"Participate", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False


Selection.Replace What:="None", Replacement:="Not Issued", LookAt:= _
xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="Change", Replacement:= _
"Changes Daily", LookAt:=xlPart, SearchOrder:=xlByColumns, _
MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
'To select the first cell
Range("A1").Select

'This refreshes all Pivot Table Element for Report
ActiveWorkbook.RefreshAll
'To auto format fit all the sheet.
Sheets("SLIDE_2").Select
Cells.Select
'Range("A7").Activate
Cells.EntireColumn.AutoFit

End Sub
Reply With Quote
  #2  
Old 07-08-2014, 12:11 PM
whatsup whatsup is offline Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Windows 7 64bit Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Office 2010 32bit
Competent Performer
 
Join Date: May 2014
Posts: 137
whatsup will become famous soon enough
Default

Hi

If you want to search or replace a sign like * you will have to search for it like that:

Code:
Cells.Find(What:="~*", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False)
Code:
ActiveCell.Replace What:="~*", Replacement:="1", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
Reply With Quote
  #3  
Old 07-10-2014, 11:09 AM
shilabrow shilabrow is offline Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Windows Vista Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Office 2007
Advanced Beginner
Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks
 
Join Date: Apr 2014
Posts: 45
shilabrow is on a distinguished road
Default

Thanks Whatsup, the ~* works great and I just replaced with "". Which works too. I appreciate the help.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use find and replace to change text to a custom style wrdy Word 7 03-11-2014 12:09 AM
Custom table of contents referencing a custom field skaboy607 Word 3 01-16-2014 06:59 AM
Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks remove color from find/replace? Cobb78 Word 1 05-26-2012 06:16 PM
quick replace, sort, change columns userman Excel 1 05-01-2012 06:24 AM
Remove the * from the SubCate, Custom Sort, Replace..Help Please - I need. Thanks Generic range for custom sort macro? tswiers Excel Programming 2 08-11-2011 02:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft