Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default If (starts with ', then delete the ')

Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a "'"
in front of all of them, and excel will not recognize them as dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default If (starts with ', then delete the ')

Can you elaborate? What does Len do? What does Right do?

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a

"'"
in front of all of them, and excel will not recognize them as

dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default If (starts with ', then delete the ')

The line

c.Value=(Right(c,Len(c)-1)

Can be interpreted as follows:

First we determine the value in cell c, for example '12/31/04
Then working inside out in the parenthesis, we take the length (Len) of the
value in the cell (in this case, 9) then subtract 1 (result = 8).
We next extract from the value of cell c, 8 characters from right to left,
resulting in 12/31/04 (without the ').
We then replace the value of cell c ('12/31/04) with those 8 characters
(12/31/04).

Len determines the length of the value and Right pulls "x" number of
characters going from left to right as in
Right(string, 1)
returns the rightmost charcter.

There are more elaborate explanations in the Excel VBA help.

HTH

wrote in message
oups.com...
Can you elaborate? What does Len do? What does Right do?

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a

"'"
in front of all of them, and excel will not recognize them as

dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default If (starts with ', then delete the ')

Hi
in the VBA editor select these functions and press F1

--
Regards
Frank Kabel
Frankfurt, Germany
schrieb im Newsbeitrag
oups.com...
Can you elaborate? What does Len do? What does Right do?

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a

"'"
in front of all of them, and excel will not recognize them as

dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default If (starts with ', then delete the ')

This is not working. Len is ignoring the apostrophe when determining
the length so this function is deleting the first number in the cell.
Any other ideas? Thank you for your help.

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a

"'"
in front of all of them, and excel will not recognize them as

dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default If (starts with ', then delete the ')

Apparently replacing the cell value with itself elimiates the apostrophe:

Sub nomoreapos()

For Each c In Selection
c.Value = c.Value
Next c

End Sub

wrote in message
oups.com...
This is not working. Len is ignoring the apostrophe when determining
the length so this function is deleting the first number in the cell.
Any other ideas? Thank you for your help.

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a

"'"
in front of all of them, and excel will not recognize them as

dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default If (starts with ', then delete the ')

Hi Michael McClellan,

One thing to be aware of - replacing all cells with their values will remove
any formulas you have. So you may want to do something like this:

Sub FixDates()
Dim c As Range

For Each c In ActiveSheet.UsedRange
If Not c.HasFormula And IsDate(c.Value) Then _
c.Value = c.Value
Next c
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Michael Malinsky wrote:
Apparently replacing the cell value with itself elimiates the
apostrophe:

Sub nomoreapos()

For Each c In Selection
c.Value = c.Value
Next c

End Sub

wrote in message
oups.com...
This is not working. Len is ignoring the apostrophe when determining
the length so this function is deleting the first number in the cell.
Any other ideas? Thank you for your help.

Don Guillett wrote:
one way?
Sub nomoreapos()
For Each c In Selection
c.Value = Right(c, Len(c) - 1)
Next c

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with
a "'" in front of all of them, and excel will not recognize them
as dates. I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 146
Default If (starts with ', then delete the ')

Easier than mucking about in VBA:

Copy a blank cell
Select the cells which have an apostrophe as the first character (which is not
recognized by VBA or Excel)
Edit menu Paste Special Values and Operation - Add options

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

wrote:

Gentlemen (and Ladies),

Unfortunately the last person who did this job entered dates with a "'"
in front of all of them, and excel will not recognize them as dates.
I'm looking for some code that will do the following:

rownum = 7

Do
if Range("P" & rownum).Value [begins with "'"] then
[delete the "'"]
rownum = rownum + 1
Does anybody know how to do something like this?


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
Excel E-2007 starts, but Installer also starts 3 times??? Thanks for the Great Tip Setting up and Configuration of Excel 0 January 24th 10 03:21 AM
Excel Starts When I hit te Zero Key [email protected] Excel Discussion (Misc queries) 0 October 7th 08 11:12 PM
Zero starts of a number Lisa Excel Worksheet Functions 5 June 9th 06 09:48 PM
Delete row if cell starts with ........... mohd21uk via OfficeKB.com New Users to Excel 2 May 15th 06 05:50 PM
formula starts : =+ what does plus indicate? pskwaak Excel Worksheet Functions 3 February 24th 06 02:46 AM


All times are GMT +1. The time now is 04:09 PM.

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"