I am currently working on coding button in which I found problem when I tried to click at button. the message window runtime error 1004,
application-defined or object-defined error is pop up.
here is my code:
Private Sub CommandButton1_Click()
Dim s As Single
Dim t As Integer
Application.ScreenUpdating = False
s = Worksheets("Sheet2").Range("J6").Value
s = s * 1.1
Worksheets("Sheet2").Range("J6").Value = s
Worksheets("Sheet2").Range("K6").Value = 0
Worksheets("Sheet2").Range("L6").Value = Date
With ActiveWorkbook.Worksheets("Sheet2").Sort
.SortFields.Clear
.SortFields.Add Key:=Range("I6"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.SetRange Range("F6:L11")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Dim r As Single
Dim count As Integer
Dim i As Integer
count = 6
For i = 1 To 6
count = i + 5
r = ActiveWorkbook.Worksheets("Sheet2").Range("I" & count).Value
If r <= 0.7 Then
ActiveWorkbook.Worksheets("Sheet2").Range(Cells(count, 6), Cells(count, 12)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End If
Next i
Application.ScreenUpdating = True
End Sub
this code is coding on Sheet1. However when I tried to create sub procedure on This Workbook object is appeared to work as what I want
back on code on Sheet1, when I put "'" in front of the following line
ActiveWorkbook.Worksheets("Sheet2").Range(Cells(count, 6), Cells(count, 12))
.Select
it's turn green and there is no error window, but it still doesn't work as I want it to
I would love to thank in advance to anyone who pass by and provide me any comment or solution. and I have to sorry for my incompetence coding, I am beginner.