Hello!
I'm running into a problem, as I run this code. It runs without any errors, but on the If formula, the cells are not clearing out. I've colored the line I think may be the problem. I'd really appreciate any help with figuring out what I'm doing wrong. Thanks!
I'm running into a problem, as I run this code. It runs without any errors, but on the If formula, the cells are not clearing out. I've colored the line I think may be the problem. I'd really appreciate any help with figuring out what I'm doing wrong. Thanks!
Rich (BB code):
Sub QtrInfo()
Dim strMainWorkbook As String
Dim strMainWorksheet As String
Dim strDetailWorkbook As String
Dim a As Integer
Dim x As Long
strMainWorkbook = ActiveWorkbook.Name
Sheets("Input").Activate
' set a as the segment code (tab names)
a = 5
strMainWorksheet = Range("A" & a).Value
strDetailWorkbook = Range("A3").Value
'Open File to get current quarter data
Workbooks.Open Filename:="C:\Documents and Settings\joddoe\Desktop\" & strDetailWorkbook, ReadOnly:=True
'Insert the correct dates into each tab A11:A22
Workbooks(strDetailWorkbook).Activate
Sheets("Rev").Range("B1").Copy
Workbooks(strMainWorkbook).Activate
Sheets(strMainWorksheet).Range("A11").PasteSpecial xlPasteValues
Workbooks(strDetailWorkbook).Activate
Sheets("Rev").Range("C1").Copy
Workbooks(strMainWorkbook).Activate
Sheets(strMainWorksheet).Range("A12").PasteSpecial xlPasteValues
Workbooks(strDetailWorkbook).Activate
Sheets("Rev").Range("D1").Copy
Workbooks(strMainWorkbook).Activate
Sheets(strMainWorksheet).Range("A13").PasteSpecial xlPasteValues
'If x is positive, clear our cells "B11:D22"
x = Sheets(strMainWorksheet).Range("D29").Value
If x > 0 Then
Range("B11:D23").ClearContents
'if x is not positive, move data up 3 rows and clear ("B23:D23")
Else
Range("B14:D22").Copy
Range("B11").PasteSpecial xlPasteValues
Range("B23:D23").ClearContents
End If
Workbooks(strDetailWorkbook).Close
End Sub