Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula from a single cell to a merged cell | Excel Discussion (Misc queries) | |||
Tabbing from single cell to merged cell | Excel Discussion (Misc queries) | |||
Very Basic Problem - Merged Cell Equals Contents of a Single Cell | Excel Worksheet Functions | |||
How to copy single cell into cell that is merged from two cells? | Excel Discussion (Misc queries) | |||
How do I copy data in single cell format to a merged cell format | Excel Discussion (Misc queries) |