Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Macro to copy a value if number

I have a group of data that in column B contains a mixture of part numbers
for some items, and qty for others. What I'd like to be able to do is copy
IF the value in the column B cell is a number to the corresponding column A
cell. If the value in the column B cell is not a number, do nothing.
(example below)

I have another macro to delete lines with a blank in that A column.

Any ideas?

Thanks in advance,

Scott


Here is what I have now:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 TGL6 Ground Kit
1 TNIA1200G
1 TSKG412

Here is what I would like to end up with:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 1 TGL6 Ground Kit
1 1 TNIA1200G
1 1 TSKG412

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy a value if number

Hi Scott

Try this one

Sub test()
Dim cell As Range
On Error Resume Next
For Each cell In Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers)
cell.Offset(0, -1).Value = cell.Value
Next
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Scott Wagner" wrote in message ...
I have a group of data that in column B contains a mixture of part numbers
for some items, and qty for others. What I'd like to be able to do is copy
IF the value in the column B cell is a number to the corresponding column A
cell. If the value in the column B cell is not a number, do nothing.
(example below)

I have another macro to delete lines with a blank in that A column.

Any ideas?

Thanks in advance,

Scott


Here is what I have now:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 TGL6 Ground Kit
1 TNIA1200G
1 TSKG412

Here is what I would like to end up with:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 1 TGL6 Ground Kit
1 1 TNIA1200G
1 1 TSKG412



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Macro to copy a value if number

Thanks! Works perfectly!




"Ron de Bruin" wrote:

Hi Scott

Try this one

Sub test()
Dim cell As Range
On Error Resume Next
For Each cell In Columns("B").SpecialCells(xlCellTypeConstants, xlNumbers)
cell.Offset(0, -1).Value = cell.Value
Next
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Scott Wagner" wrote in message ...
I have a group of data that in column B contains a mixture of part numbers
for some items, and qty for others. What I'd like to be able to do is copy
IF the value in the column B cell is a number to the corresponding column A
cell. If the value in the column B cell is not a number, do nothing.
(example below)

I have another macro to delete lines with a blank in that A column.

Any ideas?

Thanks in advance,

Scott


Here is what I have now:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 TGL6 Ground Kit
1 TNIA1200G
1 TSKG412

Here is what I would like to end up with:
Item# Qty Description
1 1 Circuit Breaker Enclosure 134
TK4V1200R
ACCESSORIES SELECTED:
1 1 TGL6 Ground Kit
1 1 TNIA1200G
1 1 TSKG412




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
Creating a macro to copy a number of charts from Excel to PPT Brian Excel Programming 0 December 16th 05 04:53 PM
Copy number that changes daily with macro RoyC Excel Programming 1 April 23rd 05 11:54 PM
Macro to copy cell contents number of columns Pierre Excel Programming 10 November 4th 04 10:54 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Macro to copy down specific number of rows JA Excel Programming 4 April 26th 04 01:37 PM


All times are GMT +1. The time now is 02:36 PM.

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"