5 pts.
 While Loop in Excel VBA
I have the basic loop and can not figure out what to write in the middle. I need to have row 9 column D populate a value from another sheet depending on the value in cell A9. Here is what I have so far:

 Private Sub Loop1() Dim myLoopCtr As Integer myLoopCtr = 0 While myLoopCtr <= 15 myLoopCtr = myLoopCtr + 1 Wend End Sub
 

Software/Hardware used:
ASKED: March 21, 2008  10:34 PM
UPDATED: April 18, 2013  2:20 PM

Answer Wiki:
Hello, Why not use a Select Case statement instead?
Sub SetMyValue()

Select Case Range("A9").Value
Case "123"
Range("D9").Value = "something"
Case "456"
Range("E5").Value = "something else"
Case Else
End Select

End Sub
Selecting cells will result in very slow code. HTH, JP Try this, changing the hello excel part of course, this should get you started:
Sub main()

Range("D9").Select
ActiveCell.FormulaR1C1 = "Hello Excel"
Range("D9").Select
Selection.Font.Bold = True
End Sub
Last Wiki Answer Submitted:  April 18, 2013  2:21 pm  by  Michael Tidmarsh   14,000 pts.
All Answer Wiki Contributors:  Michael Tidmarsh   14,000 pts. , Jerry Lees   5,320 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Be sure and check out my blog here on ITKE for more Network administration and VBSCRIPT tips.
The VBScript Network and Systems Administrator’s Cafe

 5,320 pts.