Solved

Show only first character in cell

Posted on 2012-04-09
14
243 Views
Last Modified: 2012-04-12
Hi,

If I have a cell in Excel, that contains X3, is there a way to just show X in the cell?

The number 3 should still bee in the cell, but not be shown.

Thanks in regards.
0
Comment
Question by:DennisPedersen
14 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
There are only two ways I can think of.

- make the column width narrow enough to displace the 3 to the next column and then put something in the next column so that the 3 is hidden

- use a shape which has a color which is the same as the background to cover the 3.

But both methods are not flexible to changes to the cell unless it is always x and a number.
0
 
LVL 10

Expert Comment

by:ravindran_eee
Comment Utility
You can put this formula in another cell and hide the original one. Then drag the formula to rest of the cells so that the formula will apply for the entire column.

LEFT(A1,1)
0
 

Author Comment

by:DennisPedersen
Comment Utility
Okay, I have figured out the solutions you are writing, I was looking for maybe something VBA, that could do the trick.

Maybe I should go in something conditional formating.
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Hi, Dennis.

The Hidden_Characters macro (below and attached) changes the colour of the second and subsequent characters to white for all cells in the active cell's column. Few things...
(1) It only works for strings.
(2) I was lazy and changed the colour to white. If the idea works for you, I can change the macro to use each cell's fill colour.
Sub Hidden_Characters()
Dim xLast_Row As Long
Dim xThis_Col As Long
Dim i As Long

Sheets("Sheet1").Activate

xThis_Col = ActiveCell.Column

xLast_Row = ActiveSheet.Range("A1").SpecialCells(xlLastCell).Row
If xLast_Row = 0 Then
    MsgBox ("Empty sheet. Run cancelled.")
    Exit Sub
End If

For i = 1 To xLast_Row
    
    On Error Resume Next
        If Len(Cells(i, xThis_Col)) > 1 _
            Then Cells(i, xThis_Col).Characters(Start:=2, Length:=Len(Cells(i, xThis_Col)) - 1).Font.Color = 16777215
    On Error GoTo 0

Next

End Sub

Open in new window

Regards,
Brian.Hidden-Characters.xlsm
0
 

Author Comment

by:DennisPedersen
Comment Utility
Hi Brian,

Thanks for the solution. It looks nice, but I'm having a problem with the solution. The single letter remaining should be centered in the column. But when the rest of the characters still is in the cell, it coult be a little difficult.
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Dennis,

Oh dear, that's a significant addition.

I need more information about the data...
    - are all the cells the same length?
    - besides displaying it, what else will you do with the data?

Thanks,
Brian.
0
 

Author Comment

by:DennisPedersen
Comment Utility
Hi Brian,

The cells could contain D, X, N, D3, X3 and N3

When the cells contains D3, X3 and N3 the cell should display D, X and N, but it should contain  D3, X3 and N3.

The cells should afterwards be used to manpulate with conditional formatting.

Does this make sence?
0
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.

 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
Comment Utility
Dennis,

Thanks, that's easy...Hidden-Characters-V2.xlsmRegards,
Brian.
0
 

Author Comment

by:DennisPedersen
Comment Utility
Hi Brian,

Thanks a lot, it looks like it working great :-)

But I'm not able to se where you have created the code. Could you please guide me?
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Dennis,

It was your suggestion - it's all done by Conditional Formatting.

Regards,
Brian.
0
 
LVL 80

Expert Comment

by:byundt
Comment Utility
Brian,
That was awfully clever!

Brad
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Thanks, Brad! <blush>
0
 

Author Comment

by:DennisPedersen
Comment Utility
Hi Brian,

The solution worked perfect for me. Thans a lot for your time.
0
 
LVL 26

Expert Comment

by:redmondb
Comment Utility
Thanks, Dennis. Glad to help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

762 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