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

I have a template spreadsheet that does a number of things using VBA.
One of the columns in the spreadsheet is formatted as Number with
decimal places. The problem that I am having is the user copies dat
from another spreadsheet which does not have the same format. When th
data is pasted into the template spreadsheet the column/cell has th
Number stored as Text Error. How would I fix this error via VBA befor
saving the file? In other words, how can I reformat the column back t
Number with 8 decimal places? I currently have the following, but i
does not change all of the cells (some are still stord as text).

Columns("J:K").Select
Selection.NumberFormat = "0.00000000"

Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Reformatting a cell using VBA

Hi
try the following:
with range("J1:K1000")
.NumberFormat = "0.00000000"
.value=.value
end with

--
Regards
Frank Kabel
Frankfurt, Germany


I have a template spreadsheet that does a number of things using VBA.
One of the columns in the spreadsheet is formatted as Number with 8
decimal places. The problem that I am having is the user copies

data
from another spreadsheet which does not have the same format. When
the data is pasted into the template spreadsheet the column/cell has
the Number stored as Text Error. How would I fix this error via VBA
before saving the file? In other words, how can I reformat the
column back to Number with 8 decimal places? I currently have the
following, but it does not change all of the cells (some are still
stord as text).

Columns("J:K").Select
Selection.NumberFormat = "0.00000000"

Thanks.


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Reformatting a cell using VBA

That did it. I changed it a bit to do the entire column. Thanks
lot.

with range("J:K")
.NumberFormat = "0.00000000"
.value=.value
end wit

--
Message posted from http://www.ExcelForum.com

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
Reformatting ILoveMyCorgi Excel Discussion (Misc queries) 5 January 12th 10 06:42 AM
Help With Reformatting Robert Excel Discussion (Misc queries) 0 July 23rd 09 02:56 PM
reformatting dates [email protected] Excel Discussion (Misc queries) 6 July 12th 07 09:09 PM
Reformatting a column Janna Excel Discussion (Misc queries) 4 September 14th 06 03:41 AM
need help reformatting spreadsheet Fatboymedic Excel Discussion (Misc queries) 1 November 15th 05 04:50 PM


All times are GMT +1. The time now is 01:17 PM.

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"