On 2002-05-02 06:36, Mark O'Brien wrote:
I was just trying to figure out how to do this Worksheet_Change thing. Thanks for ruining my first faux pas into WBA /board/images/smiles/icon_biggrin.gif.
I have a question though: Is it possible to variablize/parameterize the target column, for example, forcing the code to read from a cell in a worksheet called Admin?
Aladin
Well, well, well. Crossing over to the dark side are we? Wonders will never cease!
If I'm following you correctly, you want to be able to read data from a specific cell from a sheet named "Admin". (we'll use the old favourite cell, "A1")
Let's say, for example, whenever a value in column A on Sheet1 changed, we want to put the data from "Admin!A1" into "Sheet1!B1"
We would do this:
<pre>
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub 'Exit the routine if more than one cell is changing
'This usually leads to horrible errors otherwise
If Target.Column = 1 Then
Sheets("Sheet1").Range("B1").Value = Sheets("Admin").Range("A1").Value
End If
End Sub</pre>
If I didn't pick up your example properly, just repost. Basically, anything you can do in a spreadsheet using Excel functions can be accomplished using VBA. (the trick is to find out how to do it /board/images/smiles/icon_biggrin.gif )