If statement(rookies)


K

KK

Private Sub cbStart_Click()

Workbooks.Open (tbFile)
Sheets(1).Activate

Dim x As Integer
Dim z As Integer




For x = 2 To 10

Application.Goto Reference:="R" & x & "C13"
ActiveCell.FormulaR1C1 = "=(LEFT(RC[-8],LEN(RC[-8])-4)+1)"
ActiveCell.Value = z




If z > 10 Then
ActiveCell.Value = "Y"

Else
ActiveCell.Value = "N"

End If


Next x

ActiveWorkbook.SaveAs (tbFile)


End Sub



If not use the if statement , Z value will show, but if i use IF statement
,i cant use the Z value to compare with integer ,anything wrong ?
 
Ad

Advertisements

K

KK

Sam, thanks a lot......It work....

Sam Wilson said:
Do you mean

z = activecell.value

instead of

activecell.value = z

?

KK said:
Private Sub cbStart_Click()

Workbooks.Open (tbFile)
Sheets(1).Activate

Dim x As Integer
Dim z As Integer




For x = 2 To 10

Application.Goto Reference:="R" & x & "C13"
ActiveCell.FormulaR1C1 = "=(LEFT(RC[-8],LEN(RC[-8])-4)+1)"
ActiveCell.Value = z




If z > 10 Then
ActiveCell.Value = "Y"

Else
ActiveCell.Value = "N"

End If


Next x

ActiveWorkbook.SaveAs (tbFile)


End Sub



If not use the if statement , Z value will show, but if i use IF statement
,i cant use the Z value to compare with integer ,anything wrong ?
 
Ad

Advertisements

S

Sam Wilson

Good.

If you mark that as the answer other people can search for it and might help
themselves.

KK said:
Sam, thanks a lot......It work....

Sam Wilson said:
Do you mean

z = activecell.value

instead of

activecell.value = z

?

KK said:
Private Sub cbStart_Click()

Workbooks.Open (tbFile)
Sheets(1).Activate

Dim x As Integer
Dim z As Integer




For x = 2 To 10

Application.Goto Reference:="R" & x & "C13"
ActiveCell.FormulaR1C1 = "=(LEFT(RC[-8],LEN(RC[-8])-4)+1)"
ActiveCell.Value = z




If z > 10 Then
ActiveCell.Value = "Y"

Else
ActiveCell.Value = "N"

End If


Next x

ActiveWorkbook.SaveAs (tbFile)


End Sub



If not use the if statement , Z value will show, but if i use IF statement
,i cant use the Z value to compare with integer ,anything wrong ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Looping(Rookies) 4
workbook open in looping 2
Using a sub within a function 1
Help with Index formula 2
Can you speed up this code? 2
listbox concatenate 2
macro 1
On Error GoTo stops working 2

Top