Minggu, 28 April 2013

[ExcelVBA] Re: Off Topic: TRIM or a different function as part of loop

 

Hi, Manny,

If the column you are using for that value is always that column, then simply importing the data "text only" should preserve the destination format.

If your method of importing is causing the format of that column to change, then just insert a line of code (record a macro to get the code) to format that column back to what it is after the import.

If the column heading is dynamic (not always column C, for example), then there must be a column heading you can "find", then designate the found column as your target column for the format change. (record a macro to get the "find" function and options written for you).

As you can see, recording macros will teach you VBA very quickly - although it is not always the most efficient code.

Donn

--- In ExcelVBA@yahoogroups.com, "Manny" <mgarza@...> wrote:
>
> I have a column in Excel that is formatted by default as a date with the following format m/d/yyyy h:mm:ss AM/PM
> The problem I'm having is sometimes the value getting imported does not have the h:mm:ss part of the date so Excel displays it as number as text. When I check the actual value in the cell I notice there are 3 null values after the date number.
>
> If I click in the cell with a date number and hit enter Excel recognizes the date number and converts it into a date and life is sweet again.
>
> What kind of loop can I use to have VBA check the cell and if needed convert the date number as text into date while leaving the cells that are already displayed correctly as is?
>
> Thanks,
>

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
MARKETPLACE


.

__,_._,___

Tidak ada komentar:

Posting Komentar