Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Solution needed


Hi All,

I have VBA code which adds 99 before 10 digits and differs if the
digits chnage its perfectly workin but if i copy paste the data say from
C1:C10
into A1 its showing an run time error13.Here's my code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Len(Target.Value) < 12 And Target.Value = 0 Then
Target.Value = Left("990000000000", 12 - Len(Target.Value)) &
Target.Value
End If
End If
End Sub

Any help would be appreciated.

Thanks & Regards,

Raja


--
Raja
------------------------------------------------------------------------
Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115104

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Solution needed

Try this code instead...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
On Error GoTo FixItUp
Application.EnableEvents = False
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Target.Value = Format(Target.Value, "990000000000")
End If
FixItUp:
Application.EnableEvents = True
End Sub

--
Rick (MVP - Excel)


"Raja" wrote in message
...

Hi All,

I have VBA code which adds 99 before 10 digits and differs if the
digits chnage its perfectly workin but if i copy paste the data say from
C1:C10
into A1 its showing an run time error13.Here's my code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Len(Target.Value) < 12 And Target.Value = 0 Then
Target.Value = Left("990000000000", 12 - Len(Target.Value)) &
Target.Value
End If
End If
End Sub

Any help would be appreciated.

Thanks & Regards,

Raja


--
Raja
------------------------------------------------------------------------
Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=115104


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Solution needed

You might have to format the cells in the column using 000000000000 in order
to get them to display all 12 digits.

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Try this code instead...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
On Error GoTo FixItUp
Application.EnableEvents = False
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Target.Value = Format(Target.Value, "990000000000")
End If
FixItUp:
Application.EnableEvents = True
End Sub

--
Rick (MVP - Excel)


"Raja" wrote in message
...

Hi All,

I have VBA code which adds 99 before 10 digits and differs if the
digits chnage its perfectly workin but if i copy paste the data say from
C1:C10
into A1 its showing an run time error13.Here's my code:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Len(Target.Value) < 12 And Target.Value = 0 Then
Target.Value = Left("990000000000", 12 - Len(Target.Value)) &
Target.Value
End If
End If
End Sub

Any help would be appreciated.

Thanks & Regards,

Raja


--
Raja
------------------------------------------------------------------------
Raja's Profile: http://www.thecodecage.com/forumz/member.php?userid=497
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=115104



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Solution needed


Hi Raja,
I hate to have to remind another rule, but it's very important titles
describe your problem. When another member uses the search function, "
solution needed" won't help him much would it?

Thread Title


--
Pecoflyer

Cheers -

'Firefox 3.5' (http://www.mozilla.com/en-US/firefox/all-beta.html)
really IS fast !
------------------------------------------------------------------------
Pecoflyer's Profile: http://www.thecodecage.com/forumz/member.php?userid=14
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115104

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
Possible Array Solution Needed? [email protected] Excel Discussion (Misc queries) 2 July 7th 08 03:31 PM
Lookup solution needed drucey[_32_] Excel Programming 0 April 21st 06 05:13 PM
Function or VBA Solution Needed FireGeek822 Excel Programming 4 October 31st 05 09:05 PM
Function or VBA Solution Needed FireGeek822 Excel Programming 0 October 27th 05 08:05 PM
Solution Needed, please help! Rizitsu Excel Programming 2 November 26th 04 01:43 PM


All times are GMT +1. The time now is 08:27 AM.

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"