PC Review


Reply
Thread Tools Rate Thread

How to check the last digit of each cells vaue in the column

 
 
tlee
Guest
Posts: n/a
 
      26th May 2009
Hi all,

Could anyone know how to use Macro to check the last digit (1 to 9) of the
cell value?

e.g.
Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
Cell A2 = 201, 202, ........., 209 then it will be multiply by 10

Thanks

Tlee

 
Reply With Quote
 
 
 
 
macropod
Guest
Posts: n/a
 
      26th May 2009
Hi tlee,

Try:
=MOD(A1*10,10)
copied down as far as needed

--
Cheers
macropod
[Microsoft MVP - Word]


"tlee" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
> Hi all,
>
> Could anyone know how to use Macro to check the last digit (1 to 9) of the
> cell value?
>
> e.g.
> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>
> Thanks
>
> Tlee
>

 
Reply With Quote
 
tlee
Guest
Posts: n/a
 
      26th May 2009
Hi Macropod,

Thanks for your message first.

However, how do I change to Macro VBA? since I would like to let it check
automatically.

tlee


> Hi tlee,
>
> Try:
> =MOD(A1*10,10)
> copied down as far as needed
>
> --
> Cheers
> macropod
> [Microsoft MVP - Word]
>
>
> "tlee" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi all,
>>
>> Could anyone know how to use Macro to check the last digit (1 to 9) of
>> the cell value?
>>
>> e.g.
>> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
>> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>>
>> Thanks
>>
>> Tlee


 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      26th May 2009
dim cell as range
for each cell in Range("A1:A500")
if right(cell.value,1)="9" Then
cell.Value = cell.value * 10
end if
next

"tlee" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi all,
>
> Could anyone know how to use Macro to check the last digit (1 to 9) of the
> cell value?
>
> e.g.
> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>
> Thanks
>
> Tlee


 
Reply With Quote
 
macropod
Guest
Posts: n/a
 
      26th May 2009
Hi tlee,

You can do it without a macro, by checking the 'Fixed Decimal' option (under Tools|Options|Edit) and setting its value to '-1'.
Note: this will affect all values in all workbooks until you uncheck the 'Fixed Decimal' option or change its value to something
else.

For an automated macro approach, which can be applied to just the specified range, you could use something like the following macro
attached to the relevant worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, ActiveSheet.Range("A1:A1000")) Is Nothing Then Exit Sub
With Application
.EnableEvents = False
If IsNumeric(Target.Value) Then Target.Value = Target.Value * 10
.EnableEvents = True
End With
End Sub

Change the range ("A1:A1000") to suit your needs.

--
Cheers
macropod
[Microsoft MVP - Word]


"tlee" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi Macropod,
>
> Thanks for your message first.
>
> However, how do I change to Macro VBA? since I would like to let it check automatically.
>
> tlee
>
>
>> Hi tlee,
>>
>> Try:
>> =MOD(A1*10,10)
>> copied down as far as needed
>>
>> --
>> Cheers
>> macropod
>> [Microsoft MVP - Word]
>>
>>
>> "tlee" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
>>> Hi all,
>>>
>>> Could anyone know how to use Macro to check the last digit (1 to 9) of the cell value?
>>>
>>> e.g.
>>> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
>>> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>>>
>>> Thanks
>>>
>>> Tlee

>


 
Reply With Quote
 
tlee
Guest
Posts: n/a
 
      31st May 2009
Hi Patrick,

Thanks for your message. And I rasie the other thread about check the
decimal point digit.

Could you help ? Thanks

tlee

> dim cell as range
> for each cell in Range("A1:A500")
> if right(cell.value,1)="9" Then
> cell.Value = cell.value * 10
> end if
> next
>
> "tlee" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
>> Hi all,
>>
>> Could anyone know how to use Macro to check the last digit (1 to 9) of
>> the cell value?
>>
>> e.g.
>> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
>> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>>
>> Thanks
>>
>> Tlee

>



 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      31st May 2009

Give this a try:

Sub dk()

x = Right(Range("A1").Value, InStr(Range("A1"), ".") + 1)
MsgBox x

End Sub

Change Range("A1") to your actual range, or object variable for a range.




"tlee" <(E-Mail Removed)> wrote in message
news:%23p%(E-Mail Removed)...
> Hi Patrick,
>
> Thanks for your message. And I rasie the other thread about check the
> decimal point digit.
>
> Could you help ? Thanks
>
> tlee
>
>> dim cell as range
>> for each cell in Range("A1:A500")
>> if right(cell.value,1)="9" Then
>> cell.Value = cell.value * 10
>> end if
>> next
>>
>> "tlee" <(E-Mail Removed)> wrote in message
>> news:#(E-Mail Removed)...
>>> Hi all,
>>>
>>> Could anyone know how to use Macro to check the last digit (1 to 9) of
>>> the cell value?
>>>
>>> e.g.
>>> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
>>> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>>>
>>> Thanks
>>>
>>> Tlee

>>

>
>



 
Reply With Quote
 
tlee
Guest
Posts: n/a
 
      5th Jun 2009
Hi JLGWhiz,

Thanks for your help!

tlee


>
> Give this a try:
>
> Sub dk()
>
> x = Right(Range("A1").Value, InStr(Range("A1"), ".") + 1)
> MsgBox x
>
> End Sub
>
> Change Range("A1") to your actual range, or object variable for a range.
>
>
>
>
> "tlee" <(E-Mail Removed)> wrote in message
> news:%23p%(E-Mail Removed)...
>> Hi Patrick,
>>
>> Thanks for your message. And I rasie the other thread about check the
>> decimal point digit.
>>
>> Could you help ? Thanks
>>
>> tlee
>>
>>> dim cell as range
>>> for each cell in Range("A1:A500")
>>> if right(cell.value,1)="9" Then
>>> cell.Value = cell.value * 10
>>> end if
>>> next
>>>
>>> "tlee" <(E-Mail Removed)> wrote in message
>>> news:#(E-Mail Removed)...
>>>> Hi all,
>>>>
>>>> Could anyone know how to use Macro to check the last digit (1 to 9) of
>>>> the cell value?
>>>>
>>>> e.g.
>>>> Cell A1 = 21, 22 ........, 29 then it will be multiply by 10
>>>> Cell A2 = 201, 202, ........., 209 then it will be multiply by 10
>>>>
>>>> Thanks
>>>>
>>>> Tlee
>>>

>>
>>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you format cells in a column to display a 50 digit binary shazglen Microsoft Excel Misc 3 23rd Jun 2009 12:29 PM
How to check the decimal number of each cells vaue in the column tlee Microsoft Excel Programming 4 5th Jun 2009 02:17 AM
Can Formulas use a certain Digit, like the 1st or 2nd Digit, in all Cells in a Range? Arnold Microsoft Excel Programming 5 2nd Aug 2007 06:09 PM
Check cells in a column Stuart Microsoft Excel Programming 2 30th Aug 2004 09:28 AM
Change 2 digit suffix in 14 digit number in a column of numbers. Brad H. Microsoft Excel Worksheet Functions 1 4th Sep 2003 04:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:34 AM.