Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

Hi

I've created a macro to copy two values to another part of the sheet.
The original cell is merged and the goal cell is not.
Normally this is not a problem, but since I started to protect the
sheet the problem has risen.

I have an idea that i cannot copy the merged cell since the cell next
to the goal cell is locked. The goal cell is not locked.
I need the cell after the goalcell to be locked so I cannot change
that.

Any ideas on how to get around this? Maybe rewriting the paste line?

Macro below:


Range("C8").Select
Selection.Copy
Range("C17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False



Range("G8").Select
Selection.Copy
Range("E17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


Thank you for any help.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cannot copy merged cell to a single cell

Drop the copy|paste special|values and just assign the value.

Dim FromCell As Range
Dim DestCell As Range

With ActiveSheet
Set FromCell = .Range("c8")
Set DestCell = .Cells.Find(What:="", _
After:=FromCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If DestCell Is Nothing Then
'do nothing
Else
DestCell.Value = FromCell.Value
End If
End With



Kasper wrote:

Hi

I've created a macro to copy two values to another part of the sheet.
The original cell is merged and the goal cell is not.
Normally this is not a problem, but since I started to protect the
sheet the problem has risen.

I have an idea that i cannot copy the merged cell since the cell next
to the goal cell is locked. The goal cell is not locked.
I need the cell after the goalcell to be locked so I cannot change
that.

Any ideas on how to get around this? Maybe rewriting the paste line?

Macro below:

Range("C8").Select
Selection.Copy
Range("C17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Range("G8").Select
Selection.Copy
Range("E17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Thank you for any help.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

On 25 Feb., 14:34, Dave Peterson wrote:
Drop the copy|paste special|values and just assign the value.

* * Dim FromCell As Range
* * Dim DestCell As Range

* * With ActiveSheet
* * * * Set FromCell = .Range("c8")
* * * * Set DestCell = .Cells.Find(What:="", _
* * * * * * * * * * * * * After:=FromCell, _
* * * * * * * * * * * * * LookIn:=xlFormulas, _
* * * * * * * * * * * * * LookAt:=xlPart, _
* * * * * * * * * * * * * Searchorder:=xlByColumns, _
* * * * * * * * * * * * * SearchDirection:=xlNext, _
* * * * * * * * * * * * * MatchCase:=False, _
* * * * * * * * * * * * * SearchFormat:=False)

* * * * If DestCell Is Nothing Then
* * * * * * 'do nothing
* * * * Else
* * * * * * DestCell.Value = FromCell.Value
* * * * End If
* * End With





Kasper wrote:

Hi


I've created a macro to copy two values to another part of the sheet.
The original cell is merged and the goal cell is not.
Normally this is not a problem, but since I started to protect the
sheet the problem has risen.


I have an idea that i cannot copy the merged cell since the cell next
to the goal cell is locked. The goal cell is not locked.
I need the cell after the goalcell to be locked so I cannot change
that.


Any ideas on how to get around this? Maybe rewriting the paste line?


Macro below:


Range("C8").Select
* * Selection.Copy
* * Range("C17").Select
* * Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False


* * Range("G8").Select
* * Selection.Copy
* * Range("E17").Select
* * Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * Application.CutCopyMode = False


Thank you for any help.


--

Dave Peterson- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


Hi Dave

Thank you... I wil give it a try...


/Kasper
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

On 25 Feb., 14:34, Dave Peterson wrote:
Drop the copy|paste special|values and just assign the value.

* * Dim FromCell As Range
* * Dim DestCell As Range

* * With ActiveSheet
* * * * Set FromCell = .Range("c8")
* * * * Set DestCell = .Cells.Find(What:="", _
* * * * * * * * * * * * * After:=FromCell, _
* * * * * * * * * * * * * LookIn:=xlFormulas, _
* * * * * * * * * * * * * LookAt:=xlPart, _
* * * * * * * * * * * * * Searchorder:=xlByColumns, _
* * * * * * * * * * * * * SearchDirection:=xlNext, _
* * * * * * * * * * * * * MatchCase:=False, _
* * * * * * * * * * * * * SearchFormat:=False)

* * * * If DestCell Is Nothing Then
* * * * * * 'do nothing
* * * * Else
* * * * * * DestCell.Value = FromCell.Value
* * * * End If
* * End With





Kasper wrote:

Hi


I've created a macro to copy two values to another part of the sheet.
The original cell is merged and the goal cell is not.
Normally this is not a problem, but since I started to protect the
sheet the problem has risen.


I have an idea that i cannot copy the merged cell since the cell next
to the goal cell is locked. The goal cell is not locked.
I need the cell after the goalcell to be locked so I cannot change
that.


Any ideas on how to get around this? Maybe rewriting the paste line?


Macro below:


Range("C8").Select
* * Selection.Copy
* * Range("C17").Select
* * Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False


* * Range("G8").Select
* * Selection.Copy
* * Range("E17").Select
* * Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
* * Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
* * * * :=False, Transpose:=False
* * Application.CutCopyMode = False


Thank you for any help.


--

Dave Peterson- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


I do have one objection... I need the macro to start searching after
an empty cell from C17 and down, not directly under "FromCell". How do
I do this?
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cannot copy merged cell to a single cell

After:=.range("C17"), _

(I tried to match what your posted code did <bg.)

Kasper wrote:
<<snipped
I do have one objection... I need the macro to start searching after
an empty cell from C17 and down, not directly under "FromCell". How do
I do this?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cannot copy merged cell to a single cell

I tried to match what your code did, but I didn't do it right!

Kasper wrote:

On 25 Feb., 14:34, Dave Peterson wrote:
Drop the copy|paste special|values and just assign the value.

Dim FromCell As Range
Dim DestCell As Range

With ActiveSheet
Set FromCell = .Range("c8")
Set DestCell = .Cells.Find(What:="", _
After:=FromCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If DestCell Is Nothing Then
'do nothing
Else
DestCell.Value = FromCell.Value
End If
End With





Kasper wrote:

Hi


I've created a macro to copy two values to another part of the sheet.
The original cell is merged and the goal cell is not.
Normally this is not a problem, but since I started to protect the
sheet the problem has risen.


I have an idea that i cannot copy the merged cell since the cell next
to the goal cell is locked. The goal cell is not locked.
I need the cell after the goalcell to be locked so I cannot change
that.


Any ideas on how to get around this? Maybe rewriting the paste line?


Macro below:


Range("C8").Select
Selection.Copy
Range("C17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


Range("G8").Select
Selection.Copy
Range("E17").Select
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, Searchorder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False


Thank you for any help.


--

Dave Peterson- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


I do have one objection... I need the macro to start searching after
an empty cell from C17 and down, not directly under "FromCell". How do
I do this?


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

On 25 Feb., 14:55, Dave Peterson wrote:
I tried to match what your code did, but I didn't do it right!





Kasper wrote:

On 25 Feb., 14:34, Dave Peterson wrote:
Drop the copy|paste special|values and just assign the value.


* * Dim FromCell As Range
* * Dim DestCell As Range


* * With ActiveSheet
* * * * Set FromCell = .Range("c8")
* * * * Set DestCell = .Cells.Find(What:="", _
* * * * * * * * * * * * * After:=FromCell, _
* * * * * * * * * * * * * LookIn:=xlFormulas, _
* * * * * * * * * * * * * LookAt:=xlPart, _
* * * * * * * * * * * * * Searchorder:=xlByColumns, _
* * * * * * * * * * * * * SearchDirection:=xlNext, _
* * * * * * * * * * * * * MatchCase:=False, _
* * * * * * * * * * * * * SearchFormat:=False)


* * * * If DestCell Is Nothing Then
* * * * * * 'do nothing
* * * * Else
* * * * * * DestCell.Value = FromCell.Value
* * * * End If
* * End With


Kasper wrote:


Hi


I've created a macro to copy two values to another part of the sheet.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

The macro ended up being:

Dim FromCell As Range
Dim DestCell As Range


With ActiveSheet
Set FromCell = .Range("c8")
Set DestCell = .Cells.Find(What:="", _
After:=.Range("C17"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
Set FromCell2 = .Range("G8")
Set DestCell2 = .Cells.Find(What:="", _
After:=.Range("E17"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)


If DestCell Or DestCell2 Is Nothing Then
'do nothing
Else
DestCell.Value = FromCell.Value
DestCell2.Value = FromCell2.Value
End If
End With


Although the "If DestCell Or DestCell2 Is Nothing Then" doesn't seem
to stop the macro. It runs through the "else" part anyway.
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

Although the "If DestCell Or DestCell2 Is Nothing Then" doesn't seem
to stop the macro. It runs through the "else" part anyway.


Changed "Destcell" to "Fromcell" and even if I leave it blank it still
runs through with the "else" part???
  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cannot copy merged cell to a single cell

Check it this way:

If DestCell is nothing _
Or DestCell2 Is Nothing Then
'do nothing
Else

Kasper wrote:

The macro ended up being:

Dim FromCell As Range
Dim DestCell As Range

With ActiveSheet
Set FromCell = .Range("c8")
Set DestCell = .Cells.Find(What:="", _
After:=.Range("C17"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
Set FromCell2 = .Range("G8")
Set DestCell2 = .Cells.Find(What:="", _
After:=.Range("E17"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
Searchorder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If DestCell Or DestCell2 Is Nothing Then
'do nothing
Else
DestCell.Value = FromCell.Value
DestCell2.Value = FromCell2.Value
End If
End With

Although the "If DestCell Or DestCell2 Is Nothing Then" doesn't seem
to stop the macro. It runs through the "else" part anyway.


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell



Although the "If DestCell Or DestCell2 Is Nothing Then" doesn't seem
to stop the macro. It runs through the "else" part anyway.


--

Dave Peterson- Skjul tekst i anførselstegn -

- Vis tekst i anførselstegn -


Well it doesn't work as I intended... If i fill out either DestCell og
DestCell2 it still copies the one value. Is there a way to stop the
macro if either is empty.
I tried Exit Sub but that doesn't seem to work.

Don't know if this is relevant but FromCell and Fromcell2 is a merged
cell.

  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

Tried this:

If FromCell Is Nothing _
Or FromCell2 Is Nothing Then Exit Sub
'do nothing
Else
DestCell.Value = FromCell.Value
DestCell2.Value = FromCell2.Value
End If.

But this Gives an error: Compile error - ELSE without IF?
  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Cannot copy merged cell to a single cell

FromCell and FromCell2 are always going to be assigned to ranges. That's what
these two lines do:

Set FromCell = .Range("c8")
Set FromCell2 = .Range("G8")


If you want to check to see if the either destcell or destcell2 is empty:

if destcell.value = "" _
or destcell2.value = "" then
'do nothing
else
.....



Kasper wrote:

Tried this:

If FromCell Is Nothing _
Or FromCell2 Is Nothing Then Exit Sub
'do nothing
Else
DestCell.Value = FromCell.Value
DestCell2.Value = FromCell2.Value
End If.

But this Gives an error: Compile error - ELSE without IF?


--

Dave Peterson
  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 48
Default Cannot copy merged cell to a single cell

On 26 Feb., 14:01, Dave Peterson wrote:
FromCell and FromCell2 are always going to be assigned to ranges. *That's what
these two lines do:

* * * * Set FromCell = .Range("c8")
* * * * Set FromCell2 = .Range("G8")


If you want to check to see if the either destcell or destcell2 is empty:

* *if destcell.value = "" _
* * *or destcell2.value = "" then
* * * *'do nothing
* *else
* * * .....

Kasper wrote:

Tried this:


*If FromCell Is Nothing _
* * * * Or FromCell2 Is Nothing Then Exit Sub
* * * * * * 'do nothing
* * * * Else
* * * * * * DestCell.Value = FromCell.Value
* * * * * * DestCell2.Value = FromCell2.Value
* * * * End If.


But this Gives an error: Compile error - ELSE without IF?


--

Dave Peterson


It works as intended.

Thank your for your time and help.

/Kasper
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
Formula from a single cell to a merged cell Rodders Excel Discussion (Misc queries) 4 July 29th 08 06:41 AM
Tabbing from single cell to merged cell sparkle Excel Discussion (Misc queries) 0 May 24th 07 01:56 AM
Very Basic Problem - Merged Cell Equals Contents of a Single Cell jollynicechap Excel Worksheet Functions 3 December 29th 06 08:16 PM
How to copy single cell into cell that is merged from two cells? Rod Excel Discussion (Misc queries) 3 January 22nd 06 09:24 PM
How do I copy data in single cell format to a merged cell format Paul Excel Discussion (Misc queries) 1 June 27th 05 11:00 AM


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