CHANGE CELL BASED ON TWO OTHER CELLS' VALUES AS COORDENATES

Closed
dbsimoes92 Posts 2 Registration date Tuesday April 1, 2014 Status Member Last seen April 3, 2014 - Apr 2, 2014 at 12:55 PM
dbsimoes92 Posts 2 Registration date Tuesday April 1, 2014 Status Member Last seen April 3, 2014 - Apr 3, 2014 at 04:20 PM
Hello,
I am new at this website and in vba programming and I am looking for some assistance with my vba code. I'm trying to right a code that makes a change and then try to applies it on other tab by taking the value of one cell that returns the number of the row and the value of the next cell that returns the number of the column and select that cell and applies the change.
the error is at Cells(a, b).Select
thanks in advance for your time and help!

If Target.Row < 500 And Target.Column = 6 Then 
For x = 8 To 500
If Cells(x, 6).Value = "C" Then
a = Cells(x, 12).Value
b = Cells(x, 13).Value
Sheets("13").Select
ActiveSheet.Protect "1", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
ActiveSheet.Unprotect "1"
Cells(a, b).Select
ActiveCell.ClearContents
ActiveCell.FormulaR1C1 = "C"
ActiveSheet.Protect "1", DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowFiltering:=True
Sheets("VERSO").Select
End If
Next x
End If

Diego Simões


2 responses

Blocked Profile
Apr 2, 2014 at 03:44 PM
Ok, try this.

Instead of making the cell selection directly, formulate it into a RANGE. Try that.

If the column is always "C", then formulate it by:

somevariable="C"& a &":C"& b;
Range(somevariable).select;

"If you can't soar with the eagles, then don't fly with the flock!" - Oliver Sykes; Bring Me The Horizon
0
dbsimoes92 Posts 2 Registration date Tuesday April 1, 2014 Status Member Last seen April 3, 2014
Apr 3, 2014 at 04:20 PM
thanks ac3mark, but the "C" is the value i wanna put inside the cells at sheet "13" located in coordenates (a,b), where a and b are located at sheet "verso", where the sub is also located! but thanks for the somevariable formula, it was very useful in another worksheet of mine!
0