Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying Text vs. Numerical Values

I'm using the following code to load variable with data
from a spreadsheet. This works fine if the data is
clearly text or numeric format, but fails when the data is
sort of a hybrid. In this case, we have cell contents
that include "01", "02", etc. When these are pasted into
the new sheet, they come over as 1, 2, etc. This is a
problem.

Is there any way to use this same logic, but have it paste
the data as text (e.g., with the preceeding zero)?

Thanks, Todd


For j = 1 To LotCount
myRange.Offset(j, ColStart).Resize(1, 1).Select
mytemp = myRange.Offset(j, ColStart).Resize(1, 1).Value
If mytemp 0 Then
mytemp2 = myRange.Offset(j, 0).Resize(1, 1).Value
' MsgBox "Lot # = " & mytemp2
' MsgBox "Bid = " & mytemp
myLot(j) = mytemp2
myBid(j) = mytemp

End If

Next j

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Copying Text vs. Numerical Values

You could format the cell as Text before you put the value in.

And I'm not sure where the value goes, but something like this:

with myrange.offset(x,y).resize(1,1)
.numberformat = "@"
.value = mytemp
end with

or you could prefix it with a single quote:

myrange.offset(x,y).resize(1,1).value = "'" & mytemp

"T. Jenkins" wrote:

I'm using the following code to load variable with data
from a spreadsheet. This works fine if the data is
clearly text or numeric format, but fails when the data is
sort of a hybrid. In this case, we have cell contents
that include "01", "02", etc. When these are pasted into
the new sheet, they come over as 1, 2, etc. This is a
problem.

Is there any way to use this same logic, but have it paste
the data as text (e.g., with the preceeding zero)?

Thanks, Todd

For j = 1 To LotCount
myRange.Offset(j, ColStart).Resize(1, 1).Select
mytemp = myRange.Offset(j, ColStart).Resize(1, 1).Value
If mytemp 0 Then
mytemp2 = myRange.Offset(j, 0).Resize(1, 1).Value
' MsgBox "Lot # = " & mytemp2
' MsgBox "Bid = " & mytemp
myLot(j) = mytemp2
myBid(j) = mytemp

End If

Next j


--

Dave Peterson

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
Converting text to numerical values J New Users to Excel 1 February 16th 10 04:14 PM
text and numerical values in two columns Bev[_2_] Excel Discussion (Misc queries) 3 May 26th 08 03:12 PM
Copying only the numerical values SM New Users to Excel 2 November 7th 07 11:21 PM
text has numerical values TXEagle Excel Worksheet Functions 5 August 16th 05 11:34 PM
Assign numerical values to text codes Bridget Excel Worksheet Functions 3 April 18th 05 11:33 PM


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

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

About Us

"It's about Microsoft Excel"