View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ross ross is offline
external usenet poster
 
Posts: 81
Default Newbie in deep..... Excel and VB

Hi Brad

basicly this will do what you ask - i think!

Private Sub CommandButton1_Click()

Dim strFor As Variant
x = 1
y = 2

strFor = "=A" & x & "+b" & y

Sheets("sheet1").Cells(3, 1).Value = strFor

End Sub

You see that it's the same as your code, just with diffrent ways of
link the bite up! (the &)
However, i have ever done any thing like this, but i would wayger that
there is a better way to do it... row and colum formuals spring to
mind, but hey this get the job done.

NB. the cells(3,1) refers to row 3, col A, and so on,
toolsoptionsgenralR1C1 stlye

As for ranges

you can use somehting like

Private Sub CommandButton1_Click()

Dim MyRange As Range



With ActiveSheet
.Range(.Cells(2, 4), .Cells(4, 5)).Name = "tevor"
End With


Set MyRange = ActiveSheet.Range("tevor")

End Sub

agian there are lost of ways to define ranges and there are lots of
things you can do to change ranges,

any way hope this helps,
rosscoe