Newbie needs help

  • Thread starter Thread starter MarkJones
  • Start date Start date
M

MarkJones

This is probably very easy to do, however I've got no clue as to wha
I'm doing...

Basically I need to program a macro to do the following...

1. Create a new Sheet in an Excel Workbook
2. Draw a grid from Cells A:1 to D:10
3. Format the grid with thick lined borders in Yellow
4. Colour each cell with alternate Red and green colours.

Now I've made an effort and I've got 1 done (I think)

Insert New WorkSheet

Any help would be really appriciated as this is very important that
actually complete this
 
Sounds sort of like homework to me.
Try recording a macro while you do this. Then clean it up.
 
You can use your macro recorder to get your code Mark
Tools>Macro..Record a New Macro

Do the things you want and study the code
 
It is homework in a way, it's for a job application, the annoying thin
is I'm actually supposed to be learning Excel as part of my training.
even said to the guy doing the interview "I have never programme
anything in Excel"

Oh well, will do it the way you said, thanks
 
Mark,

Try something like the following:
Dim R As Range
Dim Rng As Range
Dim WS As Worksheet
Dim ColorRed As Boolean
Dim ColorRowRed As Boolean
Set WS = Worksheets.Add

WS.Range("A1:D10").BorderAround xlSolid, xlThick, 6
For Each R In Range("A1:D10").Rows
ColorRowRed = Not ColorRowRed
ColorRed = ColorRowRed
For Each Rng In R.Cells
If ColorRed = True Then
Rng.Interior.ColorIndex = 3
Else
Rng.Interior.ColorIndex = 4
End If
ColorRed = Not ColorRed
Next Rng
Next R


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Right I've done as you said

Sub Excel Test()

Sheets("Sheet1").Select
Sheets.Add
Range("A1:D10").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 6
End With

Range("A1,C1,B2,D2,C3,A3,B4,D4,C5,A5,B6,D6,C7,A7,B8,D8,C9,A9,B10,D10").Select
Range("D10").Activate
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
End With

Range("A2,B1,B3,C2,D1,D3,C4,D5,C6,D7,C8,D9,C10,B9,A10,A8,B7,A6,B5,A4").Select
Range("A4").Activate
Selection.Font.ColorIndex = 4
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With
Range("E11").Select
End Sub

Does that require cleaning in any way? Or would that be acceptable yo
think
 
Back
Top