PC Review


Reply
Thread Tools Rate Thread

Choose which cell to paste data

 
 
Mik
Guest
Posts: n/a
 
      8th May 2010
Using VBA, I have copied the contents / comments / color etc.. of a
particular cell (single or merged), and wish to manually select (using
mouse pointer) which cell to paste the data.

So, I guess the VBA code should pause / stop until a new cell is
chosen and confirmed.
Is this posible?

My code so far is....

Private Sub CommandButton4_Click()
' MOVE data
Dim Answer As String
Dim MyNote As String
MyNote = "Move selected data?"
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
If Answer = vbNo Then
Exit Sub
End If
Selection.Copy
With ActiveCell
.Interior.ColorIndex = xlNone
.ClearContents
.ClearComments
.UnMerge
End With
MsgBox ("Please select new cell, where data will be copied to. ")

?????????????

ActiveSheet.Paste
End Sub

Thanks in advance.
Mik
 
Reply With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      8th May 2010
Type:=8 will allow you to use the mouse:

Sub movem()
Dim r1 As Range, r2 As Range
Set r1 = Selection
Set r2 = Application.InputBox(prompt:="pick destination", Type:=8)
r1.Copy r2
End Sub
--
Gary''s Student - gsnu201002


"Mik" wrote:

> Using VBA, I have copied the contents / comments / color etc.. of a
> particular cell (single or merged), and wish to manually select (using
> mouse pointer) which cell to paste the data.
>
> So, I guess the VBA code should pause / stop until a new cell is
> chosen and confirmed.
> Is this posible?
>
> My code so far is....
>
> Private Sub CommandButton4_Click()
> ' MOVE data
> Dim Answer As String
> Dim MyNote As String
> MyNote = "Move selected data?"
> Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
> If Answer = vbNo Then
> Exit Sub
> End If
> Selection.Copy
> With ActiveCell
> .Interior.ColorIndex = xlNone
> .ClearContents
> .ClearComments
> .UnMerge
> End With
> MsgBox ("Please select new cell, where data will be copied to. ")
>
> ?????????????
>
> ActiveSheet.Paste
> End Sub
>
> Thanks in advance.
> Mik
> .
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      8th May 2010
Try this. Select the cell to copy>fire the macro>select the paste cell>macro
finishes job

Sub copytoselectionSAS()
Selection.Copy Application.InputBox(Prompt:= _
"Select your copy cell", Title:="SalesAid Software", Type:=8)
With ActiveCell
.Interior.ColorIndex = xlNone
.ClearContents
.ClearComments
.UnMerge
End With

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Mik" <(E-Mail Removed)> wrote in message
news:3d9a3e96-cf5e-4294-bbc5-(E-Mail Removed)...
> Using VBA, I have copied the contents / comments / color etc.. of a
> particular cell (single or merged), and wish to manually select (using
> mouse pointer) which cell to paste the data.
>
> So, I guess the VBA code should pause / stop until a new cell is
> chosen and confirmed.
> Is this posible?
>
> My code so far is....
>
> Private Sub CommandButton4_Click()
> ' MOVE data
> Dim Answer As String
> Dim MyNote As String
> MyNote = "Move selected data?"
> Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
> If Answer = vbNo Then
> Exit Sub
> End If
> Selection.Copy
> With ActiveCell
> .Interior.ColorIndex = xlNone
> .ClearContents
> .ClearComments
> .UnMerge
> End With
> MsgBox ("Please select new cell, where data will be copied to. ")
>
> ?????????????
>
> ActiveSheet.Paste
> End Sub
>
> Thanks in advance.
> Mik


 
Reply With Quote
 
Mik
Guest
Posts: n/a
 
      8th May 2010
On 8 May, 16:49, "Don Guillett" <dguille...@gmail.com> wrote:
> Try this. Select the cell to copy>fire the macro>select the paste cell>macro
> finishes job
>
> Sub copytoselectionSAS()
> Selection.Copy Application.InputBox(Prompt:= _
> *"Select your copy cell", Title:="SalesAid Software", Type:=8)
> *With ActiveCell
> * * .Interior.ColorIndex = xlNone
> * * .ClearContents
> * * .ClearComments
> * * .UnMerge
> End With
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguill...@gmail.com"Mik" <mhol...@safetysystemsuk.com> wrote in message
>
> news:3d9a3e96-cf5e-4294-bbc5-(E-Mail Removed)...
>
>
>
> > Using VBA, I have copied the contents / comments / color etc.. of a
> > particular cell (single or merged), and wish to manually select (using
> > mouse pointer) which cell to paste the data.

>
> > So, I guess the VBA code should pause / stop until a new cell is
> > chosen and confirmed.
> > Is this posible?

>
> > My code so far is....

>
> > Private Sub CommandButton4_Click()
> > ' MOVE data
> > Dim Answer As String
> > Dim MyNote As String
> > MyNote = "Move selected data?"
> > Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
> > If Answer = vbNo Then
> > * *Exit Sub
> > End If
> > Selection.Copy
> > With ActiveCell
> > * *.Interior.ColorIndex = xlNone
> > * *.ClearContents
> > * *.ClearComments
> > * *.UnMerge
> > End With
> > MsgBox ("Please select new cell, where data will be copied to. ")

>
> > ?????????????

>
> > ActiveSheet.Paste
> > End Sub

>
> > Thanks in advance.
> > Mik- Hide quoted text -

>
> - Show quoted text -


Thank you both for your reply.....

The cells that are being copied / moved can sometimes have a border
along one of it's edges (left or right, depending on it's location).
When i run your code, the borders also copy across to the new
location.

I don't want this to happen.
I have tried utilising the 'PasteSpecial
Paste:=xlPasteAllExceptBorders' routine, but i get errors.
Possibly entering it wrong.

Can you please assist?

Thanks
Mik
 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      9th May 2010
I am not exactly sure what you have and what you want. Is this one or more
cells to copy? Do the source cells have color,merging,comments. Do you want
to copy one or more cells with OUT these. Perhaps a sample file.
If desired, send your file to my address below. I will only look if:
1. You send a copy of this message on an inserted sheet
2. You give me the newsgroup and the subject line
3. You send a clear explanation of what you want
4. You send before/after examples and expected results.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Mik" <(E-Mail Removed)> wrote in message
news:ed49e056-eb8a-4486-b4f9-(E-Mail Removed)...
On 8 May, 16:49, "Don Guillett" <dguille...@gmail.com> wrote:
> Try this. Select the cell to copy>fire the macro>select the paste
> cell>macro
> finishes job
>
> Sub copytoselectionSAS()
> Selection.Copy Application.InputBox(Prompt:= _
> �"Select your copy cell", Title:="SalesAid Software", Type:=8)
> �With ActiveCell
> � � .Interior.ColorIndex = xlNone
> � � .ClearContents
> � � .ClearComments
> � � .UnMerge
> End With
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguill...@gmail.com"Mik" <mhol...@safetysystemsuk.com> wrote in message
>
> news:3d9a3e96-cf5e-4294-bbc5-(E-Mail Removed)...
>
>
>
> > Using VBA, I have copied the contents / comments / color etc.. of a
> > particular cell (single or merged), and wish to manually select (using
> > mouse pointer) which cell to paste the data.

>
> > So, I guess the VBA code should pause / stop until a new cell is
> > chosen and confirmed.
> > Is this posible?

>
> > My code so far is....

>
> > Private Sub CommandButton4_Click()
> > ' MOVE data
> > Dim Answer As String
> > Dim MyNote As String
> > MyNote = "Move selected data?"
> > Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
> > If Answer = vbNo Then
> > � �Exit Sub
> > End If
> > Selection.Copy
> > With ActiveCell
> > � �.Interior.ColorIndex = xlNone
> > � �.ClearContents
> > � �.ClearComments
> > � �.UnMerge
> > End With
> > MsgBox ("Please select new cell, where data will be copied to. ")

>
> > ?????????????

>
> > ActiveSheet.Paste
> > End Sub

>
> > Thanks in advance.
> > Mik- Hide quoted text -

>
> - Show quoted text -


Thank you both for your reply.....

The cells that are being copied / moved can sometimes have a border
along one of it's edges (left or right, depending on it's location).
When i run your code, the borders also copy across to the new
location.

I don't want this to happen.
I have tried utilising the 'PasteSpecial
Paste:=xlPasteAllExceptBorders' routine, but i get errors.
Possibly entering it wrong.

Can you please assist?

Thanks
Mik

 
Reply With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      9th May 2010
Your best method would be to remove the borders on the destination cell
after the paste. As Gary's Student had set the destination range to a
variable r2, you can use that variable to remove the borders..

Set r2 = Application.InputBox(prompt:="pick destination", Type:=8)
r1.Copy r2
r2.Borders.LineStyle = xlNone

Even if there are no borders to remove, this will not throw an error.

Mike F

"Mik" <(E-Mail Removed)> wrote in message
news:ed49e056-eb8a-4486-b4f9-(E-Mail Removed)...
> On 8 May, 16:49, "Don Guillett" <dguille...@gmail.com> wrote:
>> Try this. Select the cell to copy>fire the macro>select the paste
>> cell>macro
>> finishes job
>>
>> Sub copytoselectionSAS()
>> Selection.Copy Application.InputBox(Prompt:= _
>> "Select your copy cell", Title:="SalesAid Software", Type:=8)
>> With ActiveCell
>> .Interior.ColorIndex = xlNone
>> .ClearContents
>> .ClearComments
>> .UnMerge
>> End With
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> dguill...@gmail.com"Mik" <mhol...@safetysystemsuk.com> wrote in message
>>
>> news:3d9a3e96-cf5e-4294-bbc5-(E-Mail Removed)...
>>
>>
>>
>> > Using VBA, I have copied the contents / comments / color etc.. of a
>> > particular cell (single or merged), and wish to manually select (using
>> > mouse pointer) which cell to paste the data.

>>
>> > So, I guess the VBA code should pause / stop until a new cell is
>> > chosen and confirmed.
>> > Is this posible?

>>
>> > My code so far is....

>>
>> > Private Sub CommandButton4_Click()
>> > ' MOVE data
>> > Dim Answer As String
>> > Dim MyNote As String
>> > MyNote = "Move selected data?"
>> > Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "For Confirmation")
>> > If Answer = vbNo Then
>> > Exit Sub
>> > End If
>> > Selection.Copy
>> > With ActiveCell
>> > .Interior.ColorIndex = xlNone
>> > .ClearContents
>> > .ClearComments
>> > .UnMerge
>> > End With
>> > MsgBox ("Please select new cell, where data will be copied to. ")

>>
>> > ?????????????

>>
>> > ActiveSheet.Paste
>> > End Sub

>>
>> > Thanks in advance.
>> > Mik- Hide quoted text -

>>
>> - Show quoted text -

>
> Thank you both for your reply.....
>
> The cells that are being copied / moved can sometimes have a border
> along one of it's edges (left or right, depending on it's location).
> When i run your code, the borders also copy across to the new
> location.
>
> I don't want this to happen.
> I have tried utilising the 'PasteSpecial
> Paste:=xlPasteAllExceptBorders' routine, but i get errors.
> Possibly entering it wrong.
>
> Can you please assist?
>
> Thanks
> Mik


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down data want to choose more than one item for cell FranW Microsoft Excel Worksheet Functions 1 26th Feb 2010 08:44 PM
how can I choose part of the text in a cell and paste it elsewhere Ksenija Microsoft Access VBA Modules 1 30th Nov 2009 01:59 PM
choose a range to copy paste based on data in the cells aileen Microsoft Excel Programming 2 6th Oct 2008 07:12 PM
Choose merged cell and sum data PWK Microsoft Excel Worksheet Functions 1 9th Jun 2008 05:18 PM
choose a cell anywhere and have filtered data appear there? Is there a way? Cheryl Microsoft Excel Programming 2 19th May 2004 12:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:27 AM.