View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] wpreqq99@yahoo.com is offline
external usenet poster
 
Posts: 21
Default Command button caption from cell value

On May 11, 9:01*am, john wrote:
You are starting in row 5 so i which starts at a value of 1 needs to be
increased to select correct row. Therefore 1 + 4 = 5 then each time the code
loops i is incremented by 1 which returns the next rows value.

If you add more buttons but starting row remains the same, just increase the
last number of the For loop to match - in your new case, the value is 10.

--
jb



" wrote:
On May 11, 7:37 am, john wrote:
paste this code behind your form:


Private Sub UserForm_Initialize()
* * For i = 1 To 5


* * * * With ActiveSheet


* * * * * * Me.Controls("CommandButton" & i).Caption= _
* * * * * * .Range("L" & i + 4).Value


* * * * End With


* * Next
End Sub


--
jb



I got it.... thanks