+ Reply to Thread
Results 1 to 3 of 3

Change populated cell names via macro

  1. #1
    Registered User
    Join Date
    08-05-2004
    Posts
    9

    Change populated cell names via macro

    I have an Excel macro that formats a page for me. I want to add a step in my macro that basically says 'for any cell in column C that says TRUE, change to YES' and 'for any cell in column C that says FALSE, change to NO'.

    Can anyone tell me what the macro would be to read any populated cell in column C and make these changes?

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    here is one way

    Sub macro1()

    For Each cell In Sheets("Sheet1").Range("C1", Range("C65536").End(xlUp).Address)
    Select Case cell.Value
    Case True
    cell.Value = "YES'"

    Case False
    cell.Value = "NO'"
    Case Else
    End Select

    Next cell
    End Sub
    Please Login or Register  to view this content.
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    another option

    Columns("C:C").Select
    Selection.Replace What:="True", Replacement:="YES", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Selection.Replace What:="False", Replacement:="NO", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1