Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA Excel - import into cell changes cellformat

Status
Not open for further replies.

Johnomill

Technical User
Dec 19, 2001
19
NL
I'm reading data from a comma-separated-file into a worksheet. The worksheet is protected. The cells have a format with left allignment of the Euro-sign and right allignment of the value. After import the Left allignment of the Euro-sign is changed to right. How can I prevent this from happening? I tried to read the value only into the cell with
Workbooks(A).Worksheets(B).Cells(R,K).Value=Importvalue
But this doen't work.
 
Hi,
So you are opening a text file for sequential input?
Reading into a buffer and parsing values into a variable(s)?
The writing the variable(s) to specific cells?
It should work without clobbering the format, but if it is, here's what you could do...
Code:
    With Workbooks(a).Worksheets(B).Cells(R, K)
        .Value = ImportValue
       'this is a custom format for US Dollars - you can macro-record your own
        .NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
    End With
Skip,
metzgsk@voughtaircraft.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top