View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
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/