Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Look for numbers in a cell

Hi all,

I spent some time in another solution for looking account number from
worksheet, but no progress at all :(

In the first column of worksheet, there are some cells which are mad
up of names and an unique account number (6-digit-form).

However, some cells are padded with spaces, i.e.
123456 ABC
123457 CDE
345678 EFG

I would like to find all cells with account number out and highligh
them.

My code:
Sub find_Acct()
Dim result As Integer, c As Range

For Each c In ActiveSheet.Columns(1)
If IsNumeric(Left(Trim(c.Value), 6)) Then
'Highlight the cell
End If
Next c
End Sub

Any help is appreciated

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Look for numbers in a cell

Hi
try
For Each c In ActiveSheet.Columns(1)
If IsNumeric(Left(Trim(c.Value), 6)) and trim(c.value)<"" Then
c.interior.colorindex=3
End If
Next c
End Sub

But you can achieve the same without VBA (using conditional format).
e.g. try the following
- select cells A1:A100
- goto 'Format - Conditional Format'
- enter the following formula
=(ISNUMBER(--LEFT(TRIM(A1),6))*(TRIM(A1)<"")
- choose a format for these cells


--
Regards
Frank Kabel
Frankfurt, Germany


Hi all,

I spent some time in another solution for looking account number from
a worksheet, but no progress at all :(

In the first column of worksheet, there are some cells which are made
up of names and an unique account number (6-digit-form).

However, some cells are padded with spaces, i.e.
123456 ABC
123457 CDE
345678 EFG

I would like to find all cells with account number out and highlight
them.

My code:
Sub find_Acct()
Dim result As Integer, c As Range

For Each c In ActiveSheet.Columns(1)
If IsNumeric(Left(Trim(c.Value), 6)) Then
'Highlight the cell
End If
Next c
End Sub

Any help is appreciated.


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Look for numbers in a cell

Thanks.

But I cannot get rid of the same problem -- Error 13: Type Mismatch, s
I do not know how to fix it.

Warning on this line:
If Trim(c.Value) < "" And IsNumeric(Left(Trim(c.Value), 6)) Then

Thanks

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Look for numbers in a cell

Hi
try
For Each c In ActiveSheet.Columns(1)
if len(trim(c.value))=6 then
If IsNumeric(Left(Trim(c.Value), 6)) Then
c.interior.colorindex=3
end if
End If
Next c
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


Thanks.

But I cannot get rid of the same problem -- Error 13: Type Mismatch,
so I do not know how to fix it.

Warning on this line:
If Trim(c.Value) < "" And IsNumeric(Left(Trim(c.Value), 6)) Then

Thanks.


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
add multiple numbers in one cell with those numbers remaining visi TD Excel Worksheet Functions 7 May 28th 09 09:41 PM
Selecting specific numbers from a cell containing multiple numbers JRD Excel Worksheet Functions 3 January 18th 09 12:32 AM
how to extract numbers from imported cell with text and numbers? jyin Excel Discussion (Misc queries) 3 March 28th 07 01:14 PM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 3 January 19th 06 09:52 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM


All times are GMT +1. The time now is 11:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"