Ok I have this code works perfectly, now I want to do that within another sheet. opens this sheet up and do what this code does.
This is how I modified it, and it just doesnt work
I get a runtime error "no cells were found"....
Code:
Dim d1 As String
Dim d2 As String
d1 = TextBox1.Value
d2 = TextBox2.Value
Range("a6:g6").AutoFilter Field:=1, Criteria1:=">=" & d1, Operator:=xlAnd _
, Criteria2:="<=" & d2
Dim LR As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
'For i = 2 To 10000
TextBox3.Value = Range("B7:B" & LR).SpecialCells(xlCellTypeVisible).Cells(1).Value
TextBox4.Value = Range("B" & LR)
This is how I modified it, and it just doesnt work
I get a runtime error "no cells were found"....
Code:
Dim dat1 As String
Dim dat2 As String
Dim LR As Long
dat1 = TextBox1.Value
dat2 = TextBox3.Value
Workbooks("master sheet.xls").Activate
Sheets("master sheet").Range("a6:m6").AutoFilter Field:=1, Criteria1:=">=" & dat1, Operator:=xlAnd _
, Criteria2:="<=" & dat2
LR = Range("B" & Rows.Count).End(xlUp).Row
Workbooks("monthly report.xlsm").Sheets("requisition").TextBox4.Value = _
Workbooks("Master sheet.xls").Sheets("master sheet").Range("B7:B" & LR).SpecialCells(xlCellTypeVisible).Cells(1).Value
Workbooks("monthly report.xlsm").Sheets("requisition").TextBox5.Value = _
Workbooks("master sheet.xls").Sheets("master sheet").Range("B" & LR)