markeus
01-21-2011, 02:35 PM
HI
I am having some trouble with some of my code. I am trying to set a variable for a cell's address. The cell is selected from a previous loop which will go through all the values of a sheet and calculate a formula into a selected cell and then stop calculating when the cell below is empty. I then want to reset this cell address variable to the cell above as the current cell's variable would be set for the blank lower cell. Problem is I keep getting an error "object variable or with block variable not set"
this is the code:
'Do GREC
Do While cellGR <> ""
If 0.0802 * cellGR - 1.6721 < 0 Then
cellGREC.Value = "0"
cellGREC.NumberFormat = "0.00%"
Else
cellGREC.Value = (0.0802 * cellGR - 1.6721) / 100
cellGREC.NumberFormat = "0.00%"
End If
Set cellGR = cellGR.Offset(1, 0)
Set cellGREC = cellGREC.Offset(1, 0)
Set cellLastDepth = cellFirstDepth.Offset(1, 0)
Loop
End If
'create Chart
Application.ScreenUpdating = False
addrLGREC = cellGREC.Offset(-1, 0).Address
addrLGR = cellGR.Offset(-1, 0).Address
addrLD = cellFirstDepth.Offset(-1, 0).Address
xData = Range(addrFD, addrLD)
yData = Range(addrFGREC, addrLGREC)
I appologize if my tags didn't work, this is my first post. Any help is appreciated!
I am having some trouble with some of my code. I am trying to set a variable for a cell's address. The cell is selected from a previous loop which will go through all the values of a sheet and calculate a formula into a selected cell and then stop calculating when the cell below is empty. I then want to reset this cell address variable to the cell above as the current cell's variable would be set for the blank lower cell. Problem is I keep getting an error "object variable or with block variable not set"
this is the code:
'Do GREC
Do While cellGR <> ""
If 0.0802 * cellGR - 1.6721 < 0 Then
cellGREC.Value = "0"
cellGREC.NumberFormat = "0.00%"
Else
cellGREC.Value = (0.0802 * cellGR - 1.6721) / 100
cellGREC.NumberFormat = "0.00%"
End If
Set cellGR = cellGR.Offset(1, 0)
Set cellGREC = cellGREC.Offset(1, 0)
Set cellLastDepth = cellFirstDepth.Offset(1, 0)
Loop
End If
'create Chart
Application.ScreenUpdating = False
addrLGREC = cellGREC.Offset(-1, 0).Address
addrLGR = cellGR.Offset(-1, 0).Address
addrLD = cellFirstDepth.Offset(-1, 0).Address
xData = Range(addrFD, addrLD)
yData = Range(addrFGREC, addrLGREC)
I appologize if my tags didn't work, this is my first post. Any help is appreciated!