Selection copy and insert to other sheet (Macro)

Any body help with a macro please........


I have selected two cells from a row from sheet1

Is there any way to copy those cells
go to Sheet2
and insert a blank row in A1
and paste those infor on B3
tks in advance

0
Utf
3/22/2010 11:32:01 PM
excel.misc 78881 articles. 5 followers. Follow

8 Replies
1158 Views

Similar Articles

[PageSpeed] 15

The macro recorder will give you the necessary code.


Gord Dibben  MS Excel MVP

On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
<REVLOOKUPfORMULA@discussions.microsoft.com> wrote:

>Any body help with a macro please........
>
>
>I have selected two cells from a row from sheet1
>
>Is there any way to copy those cells
>go to Sheet2
>and insert a blank row in A1
>and paste those infor on B3
>tks in advance

0
Gord
3/23/2010 2:45:57 PM
Tks noted, I like the selection for copy to be selected by me, the marco only 
selects the same cells while recording.  kindly reply

"Gord Dibben" wrote:

> The macro recorder will give you the necessary code.
> 
> 
> Gord Dibben  MS Excel MVP
> 
> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> 
> >Any body help with a macro please........
> >
> >
> >I have selected two cells from a row from sheet1
> >
> >Is there any way to copy those cells
> >go to Sheet2
> >and insert a blank row in A1
> >and paste those infor on B3
> >tks in advance
> 
> .
> 
0
Utf
3/23/2010 5:53:01 PM
Sub test()
    Sheets("Sheet2").Cells(1).EntireRow.Insert
    ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
End Sub


Gord

On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
<REVLOOKUPfORMULA@discussions.microsoft.com> wrote:

>Tks noted, I like the selection for copy to be selected by me, the marco only 
>selects the same cells while recording.  kindly reply
>
>"Gord Dibben" wrote:
>
>> The macro recorder will give you the necessary code.
>> 
>> 
>> Gord Dibben  MS Excel MVP
>> 
>> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
>> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> 
>> >Any body help with a macro please........
>> >
>> >
>> >I have selected two cells from a row from sheet1
>> >
>> >Is there any way to copy those cells
>> >go to Sheet2
>> >and insert a blank row in A1
>> >and paste those infor on B3
>> >tks in advance
>> 
>> .
>> 

0
Gord
3/23/2010 7:31:45 PM
Sub test()
    ActiveCell.Resize(1, 1).Copy Destination:=Sheets("Sheet2").Range("B20")
End Sub

Thanks this works fine.  Is it possible to modify a little bit.



With the above code "the cell wherever i placed in Sheet1" is copying to B20 
(Sheet2).
When I run the Subtest() 2nd time, if b20 is not blank copy to B21
When I run the Subtest() 3rd time, if b21 is not blank copy to b22
When I run the subtest() 4th time, if b22 is not blank copy to b23..... I 
want to do it till B32


My purpose is :-
I have Students name in Sheet1
and I have a transportation form in Sheet2 Name of student column (B20 to 
32) 13 students can accomodate in one form/transportation,
just to insert the name of the selected students in the form (B20:B32) 
without typing,


Can you please suggest any code for that?

"Gord Dibben" wrote:

> Sub test()
>     Sheets("Sheet2").Cells(1).EntireRow.Insert
>     ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
> End Sub
> 
> 
> Gord
> 
> On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> 
> >Tks noted, I like the selection for copy to be selected by me, the marco only 
> >selects the same cells while recording.  kindly reply
> >
> >"Gord Dibben" wrote:
> >
> >> The macro recorder will give you the necessary code.
> >> 
> >> 
> >> Gord Dibben  MS Excel MVP
> >> 
> >> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> >> 
> >> >Any body help with a macro please........
> >> >
> >> >
> >> >I have selected two cells from a row from sheet1
> >> >
> >> >Is there any way to copy those cells
> >> >go to Sheet2
> >> >and insert a blank row in A1
> >> >and paste those infor on B3
> >> >tks in advance
> >> 
> >> .
> >> 
> 
> .
> 
0
Utf
3/24/2010 11:53:01 PM
Do you have Sheet2 filled from B1:B19 and looking for next blank cell below
that?

Which would be B20 first time you run Sub test()

Next time you run Sub test() next blank cell would be B21, etc.

Sub test()
Dim rng As Range
Dim lRow As Long
lRow = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
Set rng = Sheets("Sheet2").Range("B" & lRow)
    ActiveCell.Resize(1, 1).Copy Destination:=rng
End Sub

Please note:   ActiveCell.Resize(1, 1)  is same as  ActiveCell

No resizing is done with (1, 1)


Gord


On Wed, 24 Mar 2010 16:53:01 -0700, RE: VLOOKUP fORMULA
<REVLOOKUPfORMULA@discussions.microsoft.com> wrote:

>Sub test()
>    ActiveCell.Resize(1, 1).Copy Destination:=Sheets("Sheet2").Range("B20")
>End Sub
>
>Thanks this works fine.  Is it possible to modify a little bit.
>
>
>
>With the above code "the cell wherever i placed in Sheet1" is copying to B20 
>(Sheet2).
>When I run the Subtest() 2nd time, if b20 is not blank copy to B21
>When I run the Subtest() 3rd time, if b21 is not blank copy to b22
>When I run the subtest() 4th time, if b22 is not blank copy to b23..... I 
>want to do it till B32
>
>
>My purpose is :-
>I have Students name in Sheet1
>and I have a transportation form in Sheet2 Name of student column (B20 to 
>32) 13 students can accomodate in one form/transportation,
>just to insert the name of the selected students in the form (B20:B32) 
>without typing,
>
>
>Can you please suggest any code for that?
>
>"Gord Dibben" wrote:
>
>> Sub test()
>>     Sheets("Sheet2").Cells(1).EntireRow.Insert
>>     ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
>> End Sub
>> 
>> 
>> Gord
>> 
>> On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
>> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> 
>> >Tks noted, I like the selection for copy to be selected by me, the marco only 
>> >selects the same cells while recording.  kindly reply
>> >
>> >"Gord Dibben" wrote:
>> >
>> >> The macro recorder will give you the necessary code.
>> >> 
>> >> 
>> >> Gord Dibben  MS Excel MVP
>> >> 
>> >> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
>> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> >> 
>> >> >Any body help with a macro please........
>> >> >
>> >> >
>> >> >I have selected two cells from a row from sheet1
>> >> >
>> >> >Is there any way to copy those cells
>> >> >go to Sheet2
>> >> >and insert a blank row in A1
>> >> >and paste those infor on B3
>> >> >tks in advance
>> >> 
>> >> .
>> >> 
>> 
>> .
>> 

0
Gord
3/25/2010 3:37:43 PM
Dear Gord,

It is working fine but only little problem exists,
When I run the Sub test() first time.
It starts from B2 instead of B20, remaining everything OK.

How can I start this sequence from B20?

Thanks
Uday

"Gord Dibben" wrote:

> Do you have Sheet2 filled from B1:B19 and looking for next blank cell below
> that?
> 
> Which would be B20 first time you run Sub test()
> 
> Next time you run Sub test() next blank cell would be B21, etc.
> 
> Sub test()
> Dim rng As Range
> Dim lRow As Long
> lRow = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
> Set rng = Sheets("Sheet2").Range("B" & lRow)
>     ActiveCell.Resize(1, 1).Copy Destination:=rng
> End Sub
> 
> Please note:   ActiveCell.Resize(1, 1)  is same as  ActiveCell
> 
> No resizing is done with (1, 1)
> 
> 
> Gord
> 
> 
> On Wed, 24 Mar 2010 16:53:01 -0700, RE: VLOOKUP fORMULA
> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> 
> >Sub test()
> >    ActiveCell.Resize(1, 1).Copy Destination:=Sheets("Sheet2").Range("B20")
> >End Sub
> >
> >Thanks this works fine.  Is it possible to modify a little bit.
> >
> >
> >
> >With the above code "the cell wherever i placed in Sheet1" is copying to B20 
> >(Sheet2).
> >When I run the Subtest() 2nd time, if b20 is not blank copy to B21
> >When I run the Subtest() 3rd time, if b21 is not blank copy to b22
> >When I run the subtest() 4th time, if b22 is not blank copy to b23..... I 
> >want to do it till B32
> >
> >
> >My purpose is :-
> >I have Students name in Sheet1
> >and I have a transportation form in Sheet2 Name of student column (B20 to 
> >32) 13 students can accomodate in one form/transportation,
> >just to insert the name of the selected students in the form (B20:B32) 
> >without typing,
> >
> >
> >Can you please suggest any code for that?
> >
> >"Gord Dibben" wrote:
> >
> >> Sub test()
> >>     Sheets("Sheet2").Cells(1).EntireRow.Insert
> >>     ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
> >> End Sub
> >> 
> >> 
> >> Gord
> >> 
> >> On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> >> 
> >> >Tks noted, I like the selection for copy to be selected by me, the marco only 
> >> >selects the same cells while recording.  kindly reply
> >> >
> >> >"Gord Dibben" wrote:
> >> >
> >> >> The macro recorder will give you the necessary code.
> >> >> 
> >> >> 
> >> >> Gord Dibben  MS Excel MVP
> >> >> 
> >> >> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
> >> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
> >> >> 
> >> >> >Any body help with a macro please........
> >> >> >
> >> >> >
> >> >> >I have selected two cells from a row from sheet1
> >> >> >
> >> >> >Is there any way to copy those cells
> >> >> >go to Sheet2
> >> >> >and insert a blank row in A1
> >> >> >and paste those infor on B3
> >> >> >tks in advance
> >> >> 
> >> >> .
> >> >> 
> >> 
> >> .
> >> 
> 
> .
> 
0
Utf
3/25/2010 11:17:02 PM
I assumed that B19 was filled.

I'm going to have to work on this to figure out how to start at B20 if no
cells filled above and allow for the Offset(1, 0)

Maybe someone else with more skills will jump in meantime.


Gord

On Thu, 25 Mar 2010 16:17:02 -0700, RE: VLOOKUP fORMULA
<REVLOOKUPfORMULA@discussions.microsoft.com> wrote:

>Dear Gord,
>
>It is working fine but only little problem exists,
>When I run the Sub test() first time.
>It starts from B2 instead of B20, remaining everything OK.
>
>How can I start this sequence from B20?
>
>Thanks
>Uday
>
>"Gord Dibben" wrote:
>
>> Do you have Sheet2 filled from B1:B19 and looking for next blank cell below
>> that?
>> 
>> Which would be B20 first time you run Sub test()
>> 
>> Next time you run Sub test() next blank cell would be B21, etc.
>> 
>> Sub test()
>> Dim rng As Range
>> Dim lRow As Long
>> lRow = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
>> Set rng = Sheets("Sheet2").Range("B" & lRow)
>>     ActiveCell.Resize(1, 1).Copy Destination:=rng
>> End Sub
>> 
>> Please note:   ActiveCell.Resize(1, 1)  is same as  ActiveCell
>> 
>> No resizing is done with (1, 1)
>> 
>> 
>> Gord
>> 
>> 
>> On Wed, 24 Mar 2010 16:53:01 -0700, RE: VLOOKUP fORMULA
>> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> 
>> >Sub test()
>> >    ActiveCell.Resize(1, 1).Copy Destination:=Sheets("Sheet2").Range("B20")
>> >End Sub
>> >
>> >Thanks this works fine.  Is it possible to modify a little bit.
>> >
>> >
>> >
>> >With the above code "the cell wherever i placed in Sheet1" is copying to B20 
>> >(Sheet2).
>> >When I run the Subtest() 2nd time, if b20 is not blank copy to B21
>> >When I run the Subtest() 3rd time, if b21 is not blank copy to b22
>> >When I run the subtest() 4th time, if b22 is not blank copy to b23..... I 
>> >want to do it till B32
>> >
>> >
>> >My purpose is :-
>> >I have Students name in Sheet1
>> >and I have a transportation form in Sheet2 Name of student column (B20 to 
>> >32) 13 students can accomodate in one form/transportation,
>> >just to insert the name of the selected students in the form (B20:B32) 
>> >without typing,
>> >
>> >
>> >Can you please suggest any code for that?
>> >
>> >"Gord Dibben" wrote:
>> >
>> >> Sub test()
>> >>     Sheets("Sheet2").Cells(1).EntireRow.Insert
>> >>     ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
>> >> End Sub
>> >> 
>> >> 
>> >> Gord
>> >> 
>> >> On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
>> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> >> 
>> >> >Tks noted, I like the selection for copy to be selected by me, the marco only 
>> >> >selects the same cells while recording.  kindly reply
>> >> >
>> >> >"Gord Dibben" wrote:
>> >> >
>> >> >> The macro recorder will give you the necessary code.
>> >> >> 
>> >> >> 
>> >> >> Gord Dibben  MS Excel MVP
>> >> >> 
>> >> >> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
>> >> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>> >> >> 
>> >> >> >Any body help with a macro please........
>> >> >> >
>> >> >> >
>> >> >> >I have selected two cells from a row from sheet1
>> >> >> >
>> >> >> >Is there any way to copy those cells
>> >> >> >go to Sheet2
>> >> >> >and insert a blank row in A1
>> >> >> >and paste those infor on B3
>> >> >> >tks in advance
>> >> >> 
>> >> >> .
>> >> >> 
>> >> 
>> >> .
>> >> 
>> 
>> .
>> 

0
Gord
3/26/2010 8:24:10 PM
If you're still around<g>

Sub test()
Dim rng As Range
Dim lRow As Long
Dim startcell As Range
Set startcell = Sheets("Sheet2").Range("B20")
lRow = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
Set rng = Sheets("Sheet2").Range("B" & lRow)
If Sheets("Sheet2").Range("B20") = "" Then
    ActiveCell.Resize(1, 2).Copy Destination:=startcell
    Else
    ActiveCell.Resize(1, 2).Copy Destination:=rng
    End If
End Sub


Gord


On Fri, 26 Mar 2010 13:24:10 -0700, Gord Dibben <gorddibbATshawDOTca> wrote:

>I assumed that B19 was filled.
>
>I'm going to have to work on this to figure out how to start at B20 if no
>cells filled above and allow for the Offset(1, 0)
>
>Maybe someone else with more skills will jump in meantime.
>
>
>Gord
>
>On Thu, 25 Mar 2010 16:17:02 -0700, RE: VLOOKUP fORMULA
><REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>
>>Dear Gord,
>>
>>It is working fine but only little problem exists,
>>When I run the Sub test() first time.
>>It starts from B2 instead of B20, remaining everything OK.
>>
>>How can I start this sequence from B20?
>>
>>Thanks
>>Uday
>>
>>"Gord Dibben" wrote:
>>
>>> Do you have Sheet2 filled from B1:B19 and looking for next blank cell below
>>> that?
>>> 
>>> Which would be B20 first time you run Sub test()
>>> 
>>> Next time you run Sub test() next blank cell would be B21, etc.
>>> 
>>> Sub test()
>>> Dim rng As Range
>>> Dim lRow As Long
>>> lRow = Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Row
>>> Set rng = Sheets("Sheet2").Range("B" & lRow)
>>>     ActiveCell.Resize(1, 1).Copy Destination:=rng
>>> End Sub
>>> 
>>> Please note:   ActiveCell.Resize(1, 1)  is same as  ActiveCell
>>> 
>>> No resizing is done with (1, 1)
>>> 
>>> 
>>> Gord
>>> 
>>> 
>>> On Wed, 24 Mar 2010 16:53:01 -0700, RE: VLOOKUP fORMULA
>>> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>>> 
>>> >Sub test()
>>> >    ActiveCell.Resize(1, 1).Copy Destination:=Sheets("Sheet2").Range("B20")
>>> >End Sub
>>> >
>>> >Thanks this works fine.  Is it possible to modify a little bit.
>>> >
>>> >
>>> >
>>> >With the above code "the cell wherever i placed in Sheet1" is copying to B20 
>>> >(Sheet2).
>>> >When I run the Subtest() 2nd time, if b20 is not blank copy to B21
>>> >When I run the Subtest() 3rd time, if b21 is not blank copy to b22
>>> >When I run the subtest() 4th time, if b22 is not blank copy to b23..... I 
>>> >want to do it till B32
>>> >
>>> >
>>> >My purpose is :-
>>> >I have Students name in Sheet1
>>> >and I have a transportation form in Sheet2 Name of student column (B20 to 
>>> >32) 13 students can accomodate in one form/transportation,
>>> >just to insert the name of the selected students in the form (B20:B32) 
>>> >without typing,
>>> >
>>> >
>>> >Can you please suggest any code for that?
>>> >
>>> >"Gord Dibben" wrote:
>>> >
>>> >> Sub test()
>>> >>     Sheets("Sheet2").Cells(1).EntireRow.Insert
>>> >>     ActiveCell.Resize(1, 2).Copy Destination:=Sheets("Sheet2").Range("B3")
>>> >> End Sub
>>> >> 
>>> >> 
>>> >> Gord
>>> >> 
>>> >> On Tue, 23 Mar 2010 10:53:01 -0700, RE: VLOOKUP fORMULA
>>> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>>> >> 
>>> >> >Tks noted, I like the selection for copy to be selected by me, the marco only 
>>> >> >selects the same cells while recording.  kindly reply
>>> >> >
>>> >> >"Gord Dibben" wrote:
>>> >> >
>>> >> >> The macro recorder will give you the necessary code.
>>> >> >> 
>>> >> >> 
>>> >> >> Gord Dibben  MS Excel MVP
>>> >> >> 
>>> >> >> On Mon, 22 Mar 2010 16:32:01 -0700, RE: VLOOKUP fORMULA
>>> >> >> <REVLOOKUPfORMULA@discussions.microsoft.com> wrote:
>>> >> >> 
>>> >> >> >Any body help with a macro please........
>>> >> >> >
>>> >> >> >
>>> >> >> >I have selected two cells from a row from sheet1
>>> >> >> >
>>> >> >> >Is there any way to copy those cells
>>> >> >> >go to Sheet2
>>> >> >> >and insert a blank row in A1
>>> >> >> >and paste those infor on B3
>>> >> >> >tks in advance
>>> >> >> 
>>> >> >> .
>>> >> >> 
>>> >> 
>>> >> .
>>> >> 
>>> 
>>> .
>>> 

0
Gord
3/27/2010 2:48:45 PM
Reply:

Similar Artilces: