Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This is the part of the macro and it doesn't work the way I intended
it to do. If FromCell Is Nothing _ Or FromCell2 Is Nothing Then Exit Sub 'do nothing Else DestCell.Value = FromCell.Value DestCell2.Value = FromCell2.Value End If The Range "FromCell" is a merged cell in my sheet and even though i delete everything in it the macro still goes forward with the "else" part. How can this be? "Nothing" in vba sense means that the cell is clear? /Kasper |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
How about testing the value of the range variable rather than the variable
object? -- __________________________________ HTH Bob "Kasper" wrote in message ... This is the part of the macro and it doesn't work the way I intended it to do. If FromCell Is Nothing _ Or FromCell2 Is Nothing Then Exit Sub 'do nothing Else DestCell.Value = FromCell.Value DestCell2.Value = FromCell2.Value End If The Range "FromCell" is a merged cell in my sheet and even though i delete everything in it the macro still goes forward with the "else" part. How can this be? "Nothing" in vba sense means that the cell is clear? /Kasper |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The is Nothing does not seem to work try this instead
Sub Button1_Click() Dim FromCell As Range, FromCell2 As Range, DestCell As Range, DestCell2 As Range Set FromCell = Range("A1") Set FromCell2 = Range("B1") Set DestCell = Range("D1") Set DestCell2 = Range("E1") If FromCell = "" _ Or FromCell2 = "" Then Exit Sub 'do nothing Else DestCell.Value = FromCell.Value DestCell2.Value = FromCell2.Value End If End Sub |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On 26 Feb., 12:13, "Bob Phillips" wrote:
How about testing the value of the range variable rather than the variable object? -- __________________________________ HTH Bob "Kasper" wrote in message ... This is the part of the macro and it doesn't work the way I intended it to do. If FromCell Is Nothing _ * * * *Or FromCell2 Is Nothing Then * * * *Exit Sub * * * * * *'do nothing * * * *Else * * * * * *DestCell.Value = FromCell.Value * * * * * *DestCell2.Value = FromCell2.Value * * * *End If The Range "FromCell" is a merged cell in my sheet and even though i delete everything in it the macro still goes forward with the "else" part. How can this be? "Nothing" in vba sense means that the cell is clear? /Kasper- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - I'm not quite sure what you mean... That i should test on the given cell e.g.("E9") instead? |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Check your earlier thread.
Kasper wrote: This is the part of the macro and it doesn't work the way I intended it to do. If FromCell Is Nothing _ Or FromCell2 Is Nothing Then Exit Sub 'do nothing Else DestCell.Value = FromCell.Value DestCell2.Value = FromCell2.Value End If The Range "FromCell" is a merged cell in my sheet and even though i delete everything in it the macro still goes forward with the "else" part. How can this be? "Nothing" in vba sense means that the cell is clear? /Kasper -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Either that or the value of the object
If FromCell.Value = "" Or FromCell2.value = "" Then -- __________________________________ HTH Bob "Kasper" wrote in message ... On 26 Feb., 12:13, "Bob Phillips" wrote: How about testing the value of the range variable rather than the variable object? -- __________________________________ HTH Bob "Kasper" wrote in message ... This is the part of the macro and it doesn't work the way I intended it to do. If FromCell Is Nothing _ Or FromCell2 Is Nothing Then Exit Sub 'do nothing Else DestCell.Value = FromCell.Value DestCell2.Value = FromCell2.Value End If The Range "FromCell" is a merged cell in my sheet and even though i delete everything in it the macro still goes forward with the "else" part. How can this be? "Nothing" in vba sense means that the cell is clear? /Kasper- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - I'm not quite sure what you mean... That i should test on the given cell e.g.("E9") instead? |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks to all for your answers. They all work:-)
Have a good day. /Kasper |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
Array as a "named range" - formula ok in cells, but error as "named range" | Excel Discussion (Misc queries) | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |