Solved

Evaluating if a cell begins with a specific character

Posted on 2007-04-11
5
1,075 Views
Last Modified: 2013-12-25
I have a list with several values in a excel sheet.

All I need to do is create a macro that checks if the cell begins with #, and if it does insert a "=" sign on row B.

If the "=" sign is already in roll B, do nothing.

How can I do that? Thank you very much!
0
Comment
Question by:luizblink182
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 18888757
Row B?

This sub will go through the currently selected range and make the change:

Sub foo()

    Dim cel As Range
   
    For Each cel In Selection.Cells
        If Left(cel, 1) = "#" Then cel = "=" & Mid(cel, 2)
    Next
   
End Sub
0
 

Author Comment

by:luizblink182
ID: 18889094
Yeah I meant column B :-D

I didn't understand your code, what I was thinking of was something like this:

   For line = 1 To 10
       If Plan2.Range("A" & line) = (THIS IS THE PART I DON'T KNOW HOW TO DO) "BEGINS WITH #" Then
            Plan2.Range("B" & line).Value = "="
       End If
   Next

the rest I can do =)
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 250 total points
ID: 18889176
You need:
If Left$(Plan2.Range("A" & line),1) = "#" Then

HTH
Rory
0
 

Author Comment

by:luizblink182
ID: 18889220
That's it rorya =)

Thank you very much. Is there anyway somebody would just help me out exporting everything to a text file (without any tabs) using a macro?
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 18890801
For exporting delimited text files, I like using this little add-in I created:

http://vbaexpress.com/kb/getarticle.php?kb_id=805
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

730 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