Very very basic macro help

G

Guest

I am trying to learn visual basic through example. Can somone help me solve
this problem?

I have two different Excel workbooks, both located on my desktop.

The first is named Book1.xls The second is Book2.xls

On Sheet 1 of Book1, under column A (cells 2 through 11) I have the numbers
1 through 10.

I would like to write a macro that copies the values in these cells and
pastes them into sheet 1 of Book2, in the same cells. Also, I would like for
the cells in book 2 to be red, and the font to be bold and white.

Please help. Thanks.
 
T

Tushar Mehta

In XL turn on the macro recorder (Tools | Macro > Record new macro...),
use the UI to do whatever it is you want to do, and turn off the
recorder. XL will give you the necessary code. You can then
streamline/customize it. See
Beyond Excel's recorder
http://www.tushar-
mehta.com/excel/vba/beyond_the_macro_recorder/index.htm


--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
G

Guest

This code was produced by the macro recorder (it's a good way to learn how to
write macros):

Sub Macro1()
Windows("Book1").Activate
Range("A2:A11").Select
Selection.Copy
Windows("Book2").Activate
Range("A2").Select
ActiveSheet.Paste
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = 2
Selection.Font.Bold = True
Range("A12").Select
End Sub
 

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