LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Doesn't work when moved.

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a cell even if its contents are moved moved/replaced Darren Excel Discussion (Misc queries) 7 May 22nd 10 08:43 PM
worksheet to be moved jayesh trivedi Excel Discussion (Misc queries) 1 February 8th 09 10:18 AM
I moved a file from work to home and now my color macro does not w nick s Excel Worksheet Functions 2 December 3rd 05 02:39 PM
Maintaining a hyperlink to moved data within the work book Kev Nurse Excel Discussion (Misc queries) 1 January 28th 05 01:22 AM
When I moved data from one workbook to another... Newbie1[_3_] Excel Programming 1 April 5th 04 10:19 PM


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"