Solved

Show only first character in cell

Posted on 2012-04-09
14
253 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

623 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