Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

EXCEL - If cell contains more than 6 characters then go to other cell - How to?

Posted on 2016-08-15
3
Medium Priority
?
129 Views
Last Modified: 2016-08-29
Hi Experts.
I need a simple formula that says if a certain cell has more than 6 characters do nothing and let cursor drop down to cell below.
If there is exactly 6 character then move cursor to another cell.

Thanks  for your help.
Capture.PNGDUMMY-FILE.xlsx
0
Comment
Question by:chris pike
[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
3 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 41757044
Re-stating your question to make sure I understand:
You want an automated procedure to move the cursor to cell H7 if the number of digits/characters in the currently-selected cell is six (6).

If so:
1) There is no formula that will do this; you'll have to use VBA to reselect cells given these conditions.
2) Your "H6" cell scenario is a contradiction.  If there are either six or more characters in H6, cell H7 would be selected.

What would be your expected response if there are less than six characters in a cell?  Halt there?  

-Glenn
0
 
LVL 18

Accepted Solution

by:
xtermie earned 2000 total points
ID: 41765222
You need a macro to do that.
However Glenn is right, you need to work out the logic for this
Now, the following code will:
1) Perform your checks, as specified, for cell H2 (H3 in your reference)
Sub testx()
Dim ws As Worksheet
Set ws = Application.ActiveWorkbook.ActiveSheet

ws.Range("H2").Select
If Len(Selection.Value) = 6 Then
    ws.Range("H8").Select
Else
    If Len(Selection.Value) > 6 Then
        ws.Range("H2").Offset(1, 0).Select
    End If
End If
End Sub

Open in new window

2) Perform your checks as specified in the range you specify (H2 to H6)
Sub testx2()
Dim ws As Worksheet
Dim r As Range

Set ws = Application.ActiveWorkbook.ActiveSheet
Set r = ws.Range("H2:H6")

For Each Cell In r
Cell.Select
If Len(Selection.Value) = 6 Then
    ws.Range("H8").Select
Else
    If Len(Selection.Value) > 6 Then
        Selection.Offset(1, 0).Select
    End If
End If
Next
End Sub

Open in new window


Can be used in your Excel file as macros, hit Alt+F11 and then copy-->paste the macros
0
 

Author Closing Comment

by:chris pike
ID: 41774868
Thanks looks good.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

This article describes a serious pitfall that can happen when deleting shapes using VBA.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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.

722 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