Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default Macro For Removing Hyphens

I have a format like the following for distribution to branches:

Code Name Amount
101-2 ABC 100,000

To alert branch manger upon incorrect data insertion I have customized the
format of Code column as 000-0 and have instructed the managers to enter data
without dashes like 1012 while the conditional formatting set to highlight
cells with code <1000 and 9999 so as to confirm only a four digit one
inserted.

The branch managers usually paste the data despite of all the instructions.
I want to have a macro applied which would upon pasting the data either by
"Ctrl+V" or "Enter" have the data automatically paste special values and
remove the dashes/hyphens.

Thanx in Advance!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro For Removing Hyphens

Use a worksheet_change function. Right click tab on bottom of worksheet
(normally sheet1) and select view code. then paste following code.

Sub worksheet_change(ByVal target As Range)

For Each cell In target

cell.Value = Replace(cell, "-", "")

Next cell

End Sub


"FARAZ QURESHI" wrote:

I have a format like the following for distribution to branches:

Code Name Amount
101-2 ABC 100,000

To alert branch manger upon incorrect data insertion I have customized the
format of Code column as 000-0 and have instructed the managers to enter data
without dashes like 1012 while the conditional formatting set to highlight
cells with code <1000 and 9999 so as to confirm only a four digit one
inserted.

The branch managers usually paste the data despite of all the instructions.
I want to have a macro applied which would upon pasting the data either by
"Ctrl+V" or "Enter" have the data automatically paste special values and
remove the dashes/hyphens.

Thanx in Advance!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default Macro For Removing Hyphens

Wowo That sure was great Joel!

However, how can I apply the code only for column A and have the paste be
made only in special mode allowing values.

"Joel" wrote:

Use a worksheet_change function. Right click tab on bottom of worksheet
(normally sheet1) and select view code. then paste following code.

Sub worksheet_change(ByVal target As Range)

For Each cell In target

cell.Value = Replace(cell, "-", "")

Next cell

End Sub


"FARAZ QURESHI" wrote:

I have a format like the following for distribution to branches:

Code Name Amount
101-2 ABC 100,000

To alert branch manger upon incorrect data insertion I have customized the
format of Code column as 000-0 and have instructed the managers to enter data
without dashes like 1012 while the conditional formatting set to highlight
cells with code <1000 and 9999 so as to confirm only a four digit one
inserted.

The branch managers usually paste the data despite of all the instructions.
I want to have a macro applied which would upon pasting the data either by
"Ctrl+V" or "Enter" have the data automatically paste special values and
remove the dashes/hyphens.

Thanx in Advance!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro For Removing Hyphens

How do you know when you are in a special mode? You can use a cell like A1
to be the mode indicator and then add an if statement in code below that
looks at cell A1. I modifiied the code below so it will look at onlhy column
A.


Sub worksheet_change(ByVal target As Range)

For Each cell In target

if cell.column = 1 then
cell.Value = Replace(cell, "-", "")
end if
Next cell

End Sub


"FARAZ QURESHI" wrote:

Wowo That sure was great Joel!

However, how can I apply the code only for column A and have the paste be
made only in special mode allowing values.

"Joel" wrote:

Use a worksheet_change function. Right click tab on bottom of worksheet
(normally sheet1) and select view code. then paste following code.

Sub worksheet_change(ByVal target As Range)

For Each cell In target

cell.Value = Replace(cell, "-", "")

Next cell

End Sub


"FARAZ QURESHI" wrote:

I have a format like the following for distribution to branches:

Code Name Amount
101-2 ABC 100,000

To alert branch manger upon incorrect data insertion I have customized the
format of Code column as 000-0 and have instructed the managers to enter data
without dashes like 1012 while the conditional formatting set to highlight
cells with code <1000 and 9999 so as to confirm only a four digit one
inserted.

The branch managers usually paste the data despite of all the instructions.
I want to have a macro applied which would upon pasting the data either by
"Ctrl+V" or "Enter" have the data automatically paste special values and
remove the dashes/hyphens.

Thanx in Advance!

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
Automatically removing hyphens from ID# or SSN. FARAZ QURESHI Excel Discussion (Misc queries) 8 February 2nd 07 11:35 PM
removing a macro from a workbook Roger Excel Worksheet Functions 2 December 22nd 06 08:30 PM
Removing macro Junkman Excel Worksheet Functions 3 February 11th 06 03:11 PM
Does XL2K have "hard hyphens" (non-break hyphens)? StargateFan Excel Discussion (Misc queries) 0 January 29th 05 01:36 PM
Removing Unnecessary Macro Security Warnings o0icebox0o Excel Discussion (Misc queries) 1 November 30th 04 12:09 AM


All times are GMT +1. The time now is 02:45 AM.

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

About Us

"It's about Microsoft Excel"