Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
XL2003 on XP
Im using a Ron de Bruin macro to merge all data from workbooks in a folder(1), but it converts numeric text with leading zeros into numbers when it copies the data. The relevant portion of code is: Set destRange = BaseWks.Range("A" & rnum) 'we copy the values from the sourceRange to the destRange With sourceRange Set destRange = destRange.Resize(.Rows.Count, .Columns.Count) End With destRange.Value = sourceRange.Value Can I prevent that from happening, or do I need another macro to add the zeros back? -- Al C |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try:
destRange.Value = sourceRange.Text -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "Al" wrote: XL2003 on XP Im using a Ron de Bruin macro to merge all data from workbooks in a folder(1), but it converts numeric text with leading zeros into numbers when it copies the data. The relevant portion of code is: Set destRange = BaseWks.Range("A" & rnum) 'we copy the values from the sourceRange to the destRange With sourceRange Set destRange = destRange.Resize(.Rows.Count, .Columns.Count) End With destRange.Value = sourceRange.Value Can I prevent that from happening, or do I need another macro to add the zeros back? -- Al C |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You may have to format your destination cell also:
With SourceRange .NumberFormat = "@" End With destRange.Value = SourceRange.Text -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "Michael" wrote: Try: destRange.Value = sourceRange.Text -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "Al" wrote: XL2003 on XP Im using a Ron de Bruin macro to merge all data from workbooks in a folder(1), but it converts numeric text with leading zeros into numbers when it copies the data. The relevant portion of code is: Set destRange = BaseWks.Range("A" & rnum) 'we copy the values from the sourceRange to the destRange With sourceRange Set destRange = destRange.Resize(.Rows.Count, .Columns.Count) End With destRange.Value = sourceRange.Value Can I prevent that from happening, or do I need another macro to add the zeros back? -- Al C |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using
destRange.Value = SourceRange.Text doesn't work in my case since my source workbooks columns with regular text and numbers as well as numeric text. Preformatting the appropriate columns of the destination workbook as you suggest and using my original destRange.Value = sourceRange.Value statement does the trick. Thanks, Michael. -- Al C "Michael" wrote: |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
CSV and Numeric Strings with Leading Zeros | Excel Worksheet Functions | |||
Display leading zeros in numeric value without converting to text | Excel Discussion (Misc queries) | |||
removing leading zeros in numeric fields | Excel Discussion (Misc queries) | |||
save text field w/ leading zeros in .csv format & not lose zeros? | Excel Discussion (Misc queries) | |||
Leading Zeros in Numeric Values | Excel Worksheet Functions |