Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This sub was working just fine when the code was in the
workbook that contained the data. Now that I moved it and use the "GetOpenFile" function to get the data sheet, I get Run Time Error (1004) on the line beginning with *********. Does anyone see the problem? Thanks for all your help. Private Sub TextBox1_Change() Dim MyRange As Range, answer, mess, startR As Range, endR As Range, MRange As Range NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", Title:="Please select a file") If NewFN = False Then ' They pressed Cancel MsgBox "Stopping because you did not select a file" Exit Sub Else Workbooks.Open Filename:=NewFN End If Worksheets("No Stock Log-Daily").Range("a7").Activate Set MyRange = Range("a7") answer = 0 Do Until answer = 1 If IsEmpty(ActiveCell.Value) Then answer = 1 End If ActiveCell.Offset(1, 0).Select Loop Set endR = ActiveCell *********** Set MRange = Range(MyRange, endR)****** With Worksheets("No Stock Log-Daily").Range(MRange) Set c = .Find("wave", LookIn:=xlValues, LookAt:=xlPart) If Not c Is Nothing Then firstAddress = c.Address d = c.Row d = d - 1 Set startR = Range("L1") Set startR = startR.Offset(d, 0) Set endR = endR.Offset(0, 11) With Worksheets("No Stock Log-Daily").Range (startR, endR) Set MRange = startR Do While MRange.Row < endR.Row If MRange.MergeCells Then MRange.MergeArea.UnMerge End If Set MRange = MRange.Offset(1, 0) Loop Set MyRange = Range(startR, MRange) answer = Application.WorksheetFunction.SumIf (MyRange, "0") MsgBox "The number of No Stock events is = " & answer End With End If End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Referencing a cell even if its contents are moved moved/replaced | Excel Discussion (Misc queries) | |||
worksheet to be moved | Excel Discussion (Misc queries) | |||
I moved a file from work to home and now my color macro does not w | Excel Worksheet Functions | |||
Maintaining a hyperlink to moved data within the work book | Excel Discussion (Misc queries) | |||
When I moved data from one workbook to another... | Excel Programming |