Solved

Show only first character in cell

Posted on 2012-04-09
14
252 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
[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
14 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 37823157
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
ID: 37823158
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
ID: 37823175
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
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!

 
LVL 26

Expert Comment

by:redmondb
ID: 37823476
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
ID: 37824192
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
ID: 37824685
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
ID: 37824823
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
 
LVL 26

Accepted Solution

by:
redmondb earned 500 total points
ID: 37825070
Dennis,

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

Author Comment

by:DennisPedersen
ID: 37825151
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
ID: 37825164
Dennis,

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

Regards,
Brian.
0
 
LVL 81

Expert Comment

by:byundt
ID: 37826189
Brian,
That was awfully clever!

Brad
0
 
LVL 26

Expert Comment

by:redmondb
ID: 37826225
Thanks, Brad! <blush>
0
 

Author Comment

by:DennisPedersen
ID: 37837586
Hi Brian,

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

Expert Comment

by:redmondb
ID: 37837615
Thanks, Dennis. Glad to help.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro to convert table into pivot tables 25 71
Create email hyperlinks from regular text 3 29
Vlookup Help 3 30
Excel (XLSM) on iPad 3 39
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

752 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