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


Hi,

Writiing a macro which goes through each cell 9they are numbers) i
column 5, if the length of the cell is 1 a zero is added to the start

Below is an excerpt of the code, not quite working, many thks

Dim i
lastrow = Range("A50000").End(xlUp).Row
For i = 1 To lastrow
If Len(Cells(i, 5)) = 1 Then
Cells(i, 5) = "0" & Cells(i, 5)
End If
Nex

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=56371

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating a zero


Sub sdfsdf()
Dim i
lastrow = Range("A50000").End(xlUp).Row
For i = 1 To lastrow
If Len(CStr(Cells(i, 1))) = 1 Then
Cells(i, 1).NumberFormat = "@"
Cells(i, 1) = CStr("0" & Cells(i, 1))
End If
Next
End Su

--
MattShoreso
-----------------------------------------------------------------------
MattShoreson's Profile: http://www.excelforum.com/member.php...nfo&userid=347
View this thread: http://www.excelforum.com/showthread.php?threadid=56371

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Concatenating a zero

this worked for me

Sub test()
Dim i
Dim lastrow As Long
lastrow = Range("A50000").End(xlUp).Row
For i = 1 To lastrow
If Len(Cells(i, 5)) = 1 Then
Cells(i, 5).Value = "0" & Cells(i, 5).Value
End If
Next

End Sub

--


Gary


"T De Villiers"
wrote in message
news:T.De.Villiers.2bauo4_1153492208.9364@excelfor um-nospam.com...

Hi,

Writiing a macro which goes through each cell 9they are numbers) in
column 5, if the length of the cell is 1 a zero is added to the start.

Below is an excerpt of the code, not quite working, many thks

Dim i
lastrow = Range("A50000").End(xlUp).Row
For i = 1 To lastrow
If Len(Cells(i, 5)) = 1 Then
Cells(i, 5) = "0" & Cells(i, 5)
End If
Next


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile:
http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=563715



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating a zero


Thanks a lot Matt


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=563715

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating a zero


Thanks a lot Matt


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=563715



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating a zero


Thanks a lot Matt


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=563715

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenating a zero


Thanks a lot Matt


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=563715

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
concatenating TED Excel Worksheet Functions 3 February 13th 09 01:03 AM
concatenating Yosh Excel Discussion (Misc queries) 7 February 7th 07 09:03 PM
Concatenating % confused Excel Discussion (Misc queries) 2 September 21st 06 03:49 AM
Concatenating Himu Excel Programming 7 July 23rd 05 08:58 PM
Concatenating Metalteck New Users to Excel 10 May 4th 05 01:01 AM


All times are GMT +1. The time now is 04:16 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"