Hi All,
I have quite a long Macro which is a little rudimentary. I've been using it for years but have now made some changes to the dates on the sheet to update it ready for this financial year. If I run the macro from within the VBA editor it will execute fine and do everything I need, if I run it using the "Macros" button in Excel or using a command button it brings up my error message "The search found nothing".
I'm confused why it would function correctly and find the date using the VBA editor to run the Macro but not work when the Macro is directly run from within Excel. Any light you can shed would be helpful.
The Macro does a search of a date contained in the 'Summary' sheet cell F3 against Column A in the 'Main Data' sheet which contains 52 dates for each week end.
I'm using Excel 2010 on Windows 7 64bit.
The code is :-
Thanks very much in advance,
Paul
I have quite a long Macro which is a little rudimentary. I've been using it for years but have now made some changes to the dates on the sheet to update it ready for this financial year. If I run the macro from within the VBA editor it will execute fine and do everything I need, if I run it using the "Macros" button in Excel or using a command button it brings up my error message "The search found nothing".
I'm confused why it would function correctly and find the date using the VBA editor to run the Macro but not work when the Macro is directly run from within Excel. Any light you can shed would be helpful.
The Macro does a search of a date contained in the 'Summary' sheet cell F3 against Column A in the 'Main Data' sheet which contains 52 dates for each week end.
I'm using Excel 2010 on Windows 7 64bit.
The code is :-
Code:
Sub Summary_Fill()
Sheets("Pivot A").Select
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
Sheets("Pivot B").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Sheets("Summary").Select
'Clear row with data on in summary sheet'
Rows("14:15").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Range("C13").Select
'Search in Summary sheet for value in F3 - the date!'
Dim FindString As String
Dim Rng As Range
FindString = Sheets("Summary").Range("F3").Value
If Trim(FindString) <> "" Then
With Sheets("Main Data").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "THE SEARCH FOUND NOTHING!"
End If
End With
End If
'Copy found row to summary sheet'
ActiveCell.EntireRow.Copy
Sheets("Summary").Select
Range("A14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Thanks very much in advance,
Paul