Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Cell format change mess

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell format change mess

Can you not paste special as text?


"Ray S." wrote:

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Cell format change mess

how would I do that programmatically?

"johnmoreland21" wrote:

Can you not paste special as text?


"Ray S." wrote:

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Cell format change mess

Provided you have data on the clipboard:

Sub PasteData()
ActiveSheet.PasteSpecial Format:="Text"
End Sub


"Ray S." wrote:

how would I do that programmatically?

"johnmoreland21" wrote:

Can you not paste special as text?


"Ray S." wrote:

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Cell format change mess

If that doesnt work you could try changing the cell values to put the leading
zeros back in. If you data is simple to select it can be done easily with
code like this -

Sub test()

Dim cell As Range
For Each cell In Selection
cell = "'0" & cell.Value
Next cell
End Sub

This will force Access to read these cells as text rather than numeric.

"Ray S." wrote:

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Cell format change mess

I see...it gets a little more complicated because one of the received fields
is in long date format with spaces and time. That messes up my text format
paste because of no clear delimiter.

"johnM" wrote:

If that doesnt work you could try changing the cell values to put the leading
zeros back in. If you data is simple to select it can be done easily with
code like this -

Sub test()

Dim cell As Range
For Each cell In Selection
cell = "'0" & cell.Value
Next cell
End Sub

This will force Access to read these cells as text rather than numeric.

"Ray S." wrote:

I thought I had this worked out, but it still craps out. I have to cut and
paste selected data from a web table into excel and ultimately into MS
Access. The problem is that Access insists on treating numeric looking data
as numbers when it is not. Leading zeros are dropped and if alphabetic
symbols occur I get data type conversion errors. So, I thought I figured out
a macro to drop the web data into my clipboard then send it to Excel before
transferring it to Access. I set the cell formatting in Excel to text, but
when the clipboard data is pasted into Excel, again the formatting drops the
leading zeros.

Essentially I was doing this:

Range("A1").Select
ActiveSheet.Paste
ActiveSheet.SaveAs ("...path\imported.xls")
ClearClipboard

How can I avoid this problem?

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
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Excel Worksheet Functions 2 May 9th 23 07:42 PM
Changing the cell format doesn't change existing cell content Kate Excel Discussion (Misc queries) 2 January 14th 10 04:44 PM
Can cell format come from and change with reference cell format jclouse Excel Discussion (Misc queries) 1 November 29th 06 03:20 AM
find word in a cell then change cell format [email protected] Excel Programming 2 May 23rd 05 01:21 PM
How do i change the format of a cell based on the condition of another cell in same row? scott23 Excel Programming 1 January 6th 04 03:03 PM


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