PC Review


Reply
Thread Tools Rate Thread

Cell format change mess

 
 
=?Utf-8?B?UmF5IFMu?=
Guest
Posts: n/a
 
      1st Mar 2007
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 With Quote
 
 
 
 
=?Utf-8?B?am9obm1vcmVsYW5kMjE=?=
Guest
Posts: n/a
 
      1st Mar 2007
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?

 
Reply With Quote
 
=?Utf-8?B?UmF5IFMu?=
Guest
Posts: n/a
 
      1st Mar 2007
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?

 
Reply With Quote
 
=?Utf-8?B?am9obk0=?=
Guest
Posts: n/a
 
      2nd Mar 2007
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?

 
Reply With Quote
 
=?Utf-8?B?am9obk0=?=
Guest
Posts: n/a
 
      2nd Mar 2007
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 With Quote
 
=?Utf-8?B?UmF5IFMu?=
Guest
Posts: n/a
 
      2nd Mar 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the cell format doesn't change existing cell content Kate Microsoft Excel Misc 2 14th Jan 2010 04:44 PM
Change cell colour on formula result change, no conditional format roster_jon Microsoft Excel Programming 0 2nd Dec 2008 12:11 PM
Can cell format come from and change with reference cell format =?Utf-8?B?amNsb3VzZQ==?= Microsoft Excel Misc 1 29th Nov 2006 03:20 AM
can you send a e-mail mess to a cell phone which has text mess =?Utf-8?B?RWxpemFiZXRo?= Microsoft Outlook Discussion 1 20th Jun 2006 06:55 PM
Lock Cell Format - Allow copy and paste of data without format change Chris12InKC Microsoft Excel Worksheet Functions 1 11th Mar 2006 04:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:10 PM.