Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Remove Formatting Apostrophe

I have an excel file that is populated dynamically by an access database,
each time the excel file is opened. When I open the excel file, excel puts
an apostrophe in front of the dates in the first three columns, not allowing
users to sort properly on these dates. There are further columns containing
text, so it is not a problem.
I know how to run a macro when the user opens the excel file, but I do not
know how to write a macro that can:
1. Remove the apostraphe from the data and convert the data to date format.
2. Make sure that only the cells that are inserted from the database into
excel are converted, ie. all the cells bar cells in the first two rows as
these contain headings. How do I handle different ranges?
3. Deal with empty cells that have no data in them, to make sure they remain
blank, when the macro is run.

It would be really appreciated if anyone could help as I can't get my head
round the excel macros

cheers
matt


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Remove Formatting Apostrophe

Sub aaatester2()
Dim rng As Range, cell As Range
If Application.TransitionNavigKeys = False Then
Set rng = ActiveSheet.UsedRange.Columns("A:C").SpecialCells( _
xlConstants, xlTextValues)
For Each cell In rng
If cell.PrefixCharacter = "'" Then
cell.Formula = cell.Value
cell.NumberFormat = "mm/dd/yyyy"
End If
Next
End If

End Sub


--
Regards,
Tom Ogilvy

"matt h" wrote in message
...
I have an excel file that is populated dynamically by an access database,
each time the excel file is opened. When I open the excel file, excel puts
an apostrophe in front of the dates in the first three columns, not

allowing
users to sort properly on these dates. There are further columns

containing
text, so it is not a problem.
I know how to run a macro when the user opens the excel file, but I do not
know how to write a macro that can:
1. Remove the apostraphe from the data and convert the data to date

format.
2. Make sure that only the cells that are inserted from the database into
excel are converted, ie. all the cells bar cells in the first two rows as
these contain headings. How do I handle different ranges?
3. Deal with empty cells that have no data in them, to make sure they

remain
blank, when the macro is run.

It would be really appreciated if anyone could help as I can't get my head
round the excel macros

cheers
matt




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
Remove Apostrophe from end of number octet Excel Discussion (Misc queries) 4 April 22nd 08 06:22 PM
Remove Trailing Apostrophe Dave P Excel Discussion (Misc queries) 1 August 10th 07 12:42 AM
how to remove the apostrophe Tiffany Excel Discussion (Misc queries) 3 April 17th 07 09:54 AM
'09:00AM trying to get remove the apostrophe Kazza Excel Discussion (Misc queries) 1 April 25th 06 10:57 AM
Remove apostrophe Pat Excel Worksheet Functions 2 September 11th 05 06:27 PM


All times are GMT +1. The time now is 05:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"