Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default VBA Cut and Paste Help

Greetings,

My spreadsheet has a column with several cells which display # Value. This
error is showing up because the formula in the cell is referring to another
cell which currently has a label in it. I have a loop set up which starts at
the top of the column and goes to the bottom by incrementing. If the cell is
blank, then I skip any operation, however, if the cell contains anything (
number, label, or formula ) you cut and then past the cells value into
another cell. Everything works perfect until you get to a cell containing #
Value. Then I get a type mismatch.

For rDef = 8 to nBottom

If Worksheets("Area").Cells(rDef, refCol) < "" Then

' Code for cut & paste

End If

Next

I replaced the If statement with:

If Worksheets("Area").Cells(rDef, refCol) < "" Or
Worksheets("Area").Cells(rDef, refCol) = CVErr(xlErrValue) Then

Thinking that the first test would work for cell contents of numbers,
labels, or formulas, and the second test would work for those cells showing
# Value. Well, now I get a type mismatch on the second test when the cell is
empty.

Hopefully I have described this issue clearly. Any suggestions how I can
accomplish this task?

Thanks in advance for your help!

Ray


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA Cut and Paste Help

For rDef = 8 to nBottom
if not iserror(sheets("Area").Cells(rDef, refCol)) then
If Worksheets("Area").Cells(rDef, refCol) < "" Then

' Code for cut & paste

End If
End if
Next


--
Regards,
Tom Ogilvy


"Ray Batig" wrote in message
link.net...
Greetings,

My spreadsheet has a column with several cells which display # Value. This
error is showing up because the formula in the cell is referring to

another
cell which currently has a label in it. I have a loop set up which starts

at
the top of the column and goes to the bottom by incrementing. If the cell

is
blank, then I skip any operation, however, if the cell contains anything (
number, label, or formula ) you cut and then past the cells value into
another cell. Everything works perfect until you get to a cell containing

#
Value. Then I get a type mismatch.

For rDef = 8 to nBottom

If Worksheets("Area").Cells(rDef, refCol) < "" Then

' Code for cut & paste

End If

Next

I replaced the If statement with:

If Worksheets("Area").Cells(rDef, refCol) < "" Or
Worksheets("Area").Cells(rDef, refCol) = CVErr(xlErrValue) Then

Thinking that the first test would work for cell contents of numbers,
labels, or formulas, and the second test would work for those cells

showing
# Value. Well, now I get a type mismatch on the second test when the cell

is
empty.

Hopefully I have described this issue clearly. Any suggestions how I can
accomplish this task?

Thanks in advance for your help!

Ray




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default VBA Cut and Paste Help

Hi Tom,

Thanks for the insight.

I made this modification to get everything to work.

For rDef = 8 to nBottom
if iserror(sheets("Area").Cells(rDef, refCol)) then
goto prntCell
end if
If Worksheets("Area").Cells(rDef, refCol) < "" Then
prntCell: ' this let me skip around the problem
' Code for cut & paste


End If
Next

Tom Ogilvy wrote in message
...
For rDef = 8 to nBottom
if not iserror(sheets("Area").Cells(rDef, refCol)) then
If Worksheets("Area").Cells(rDef, refCol) < "" Then

' Code for cut & paste

End If
End if
Next


--
Regards,
Tom Ogilvy


"Ray Batig" wrote in message
link.net...
Greetings,

My spreadsheet has a column with several cells which display # Value.

This
error is showing up because the formula in the cell is referring to

another
cell which currently has a label in it. I have a loop set up which

starts
at
the top of the column and goes to the bottom by incrementing. If the

cell
is
blank, then I skip any operation, however, if the cell contains anything

(
number, label, or formula ) you cut and then past the cells value into
another cell. Everything works perfect until you get to a cell

containing
#
Value. Then I get a type mismatch.

For rDef = 8 to nBottom

If Worksheets("Area").Cells(rDef, refCol) < "" Then

' Code for cut & paste

End If

Next

I replaced the If statement with:

If Worksheets("Area").Cells(rDef, refCol) < "" Or
Worksheets("Area").Cells(rDef, refCol) = CVErr(xlErrValue) Then

Thinking that the first test would work for cell contents of numbers,
labels, or formulas, and the second test would work for those cells

showing
# Value. Well, now I get a type mismatch on the second test when the

cell
is
empty.

Hopefully I have described this issue clearly. Any suggestions how I can
accomplish this task?

Thanks in advance for your help!

Ray






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
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
'paste special', 'paste link' formatting transfer jrebello Excel Discussion (Misc queries) 2 July 25th 07 08:46 AM
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. stan-the-man Excel Worksheet Functions 7 June 14th 06 08:10 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Macro to Paste to specific line, and continue to Paste each time on next row not over tomkarakowski[_2_] Excel Programming 1 May 28th 04 06:50 PM


All times are GMT +1. The time now is 02:45 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"