Macro Help

G

Guest

Hi,
Please help to write the Macro.
In Sheet1, i have to copy the range B2..B10
In Sheet2, i want to paste this copied this range like
C4 (Data from Sheet1/B2)
D4 (Blank)
E4 (Data from sheet1/B3)
Now,
C5 (data from Sheet1/B4)
D5 (Blank)
.......
Best Regards,
 
N

Norman Jones

Hi Nad,

Try turning on the Macro recorder while you perform the
requisite actions manually.

The resultant code may be edited in order to optimise it
and obtain a more generic procedure.

If you experience problems with such editing, post your
code and indicate the specific problems.
 
D

Dave Peterson

Record a macro when you copy each cell in B2:B10 and paste into the appropriate
cell. Keep recording while you do all 9 copy|pastes and you'll have your code.

But maybe you could use a formula instead:

In Sheet2 c4:
=sheet1!b2
or
=if(sheet1!b2="","",sheet1!b2)

Maybe you don't need the macro at all????
 
D

Don Guillett

Does this do it for you?

Sub copystrange()
For i = 1 To 10
Sheets("sheet1").Cells(i + 1, 2).Copy _
Sheets("sheet2").Cells(4, i + 2)
Next
End Sub
 
G

Guest

hi
how i can run macro automaticly without creating or pressing any
buttoms

best regards
 
N

Norman Jones

Hi Ms wafaa,

'--------------
how i can run macro automaticly without creating or
pressing any buttoms
'--------------

If the code is to be executed without direct user intervention,
you would need to use an event procedure.

It is not clear, however, when the code is to be executed or
in response to what event. Perhaps you could provide some
explanatory detail?

If you are not familiar with macros, you may wish to visit
David McRitchie's:

'Getting Started With Macros And User Defined Functions'
http://www.mvps.org/dmcritchie/excel/getstarted.htm


You might also look at David's tutorials page at:

http://www.mvps.org/dmcritchie/excel/excel.htm#tutorials

For an overview of Event procedures see Chip Pearson's Events
page at:

http://www.cpearson.com/excel/events.htm
 
G

Guest

Thanks Don
Your code is very close to the answer.
With litle change i got the requiried result.
Thanks once again.
Thanks others also for answering my question.
Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top