Solved

I want to replace all Excel cell content in a range except for cells begining with specfic text

Posted on 2014-09-10
2
178 Views
Last Modified: 2014-09-10
I want to use a VBA module to replace all Excel cell content in a range except for cells begining with specfic text.
0
Comment
Question by:AMixMaster
2 Comments
 
LVL 19

Accepted Solution

by:
Ken Butters earned 500 total points
ID: 40315597
the following code will do what you want.

How to set up and run:

(1) startingStringValue needs to hold the string that you want to search for that you DO NOT want to change in the cell.
(2) newCellValue needs to hold the NEW value that you want the cells changed to.
(3) select/highlight the range you want the vba code to consider... then run the macro.

 

Sub test()
    Dim StartStringValue As String
    Dim newCellValue As String
    
    StartStringValue = "t"
    newCellValue = "NewValue"
    
    Dim aCell As Range

    For Each aCell In Selection
        If Left(aCell.Value, Len(StartStringValue)) <> StartStringValue Then
            aCell = newCellValue
        End If
    Next
End Sub

Open in new window

0
 

Author Closing Comment

by:AMixMaster
ID: 40315630
This elusive bit of code worked absolutely perfect!
Thanks Ken!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Viewers will learn how to apply various conditional formatting in Excel 2013.
Viewers will learn what comprises a theme in Excel 2013, as well as how to customize them.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now