running a Macro in 2007 which was created in 2003

Hi there, I hope you can help, I am not VB literate unfortunately but I am 
trying to run a macro with the following line of code which creates an error:

LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row

Is there a change between versions which means this line won't work any more?



0
Utf
4/22/2010 8:45:01 AM
excel.misc 78881 articles. 5 followers. Follow

8 Replies
764 Views

Similar Articles

[PageSpeed] 49

Simon,

That line is fine in E2007 provided you have 'SET' Master_Wksht but if you 
hadn't done that it wouldn't have run in earlier versions of Excel

Set Master_Wksht = Sheets("Sheet1")

What have you dimmed LastRow as it should be long. 

-- 
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that 
introduces the fewest assumptions while still sufficiently answering the 
question.


"Simon" wrote:

> Hi there, I hope you can help, I am not VB literate unfortunately but I am 
> trying to run a macro with the following line of code which creates an error:
> 
> LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> 
> Is there a change between versions which means this line won't work any more?
> 
> 
> 
0
Utf
4/22/2010 9:09:01 AM
Hmm,

I forgot the obvious question. What is the error message?
-- 
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that 
introduces the fewest assumptions while still sufficiently answering the 
question.


"Simon" wrote:

> Hi there, I hope you can help, I am not VB literate unfortunately but I am 
> trying to run a macro with the following line of code which creates an error:
> 
> LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> 
> Is there a change between versions which means this line won't work any more?
> 
> 
> 
0
Utf
4/22/2010 9:14:01 AM
Hi Simon, you've got me, being new to 2007 too. No doubt someone will soon 
give you a definitive answer soon, but until then...

I had a problem running a macro that tripped on the line, 
"Windows("Accounting.xls").Activate" which was merely to switch between 2 
windows in the one instance of Excel. It tripped the first time giving an 
error message, so I went into debugging, stepping over all the commands up to 
that one and then "stepped into" from there. It found its way through without 
an issue and then worked perfectly after that. So its possible that if you do 
the same, yours too may "settle in" (OK, some Excel geek can ridicule the 
terminology, but it worked ;-). )

Remember that any commands before the one that tripped will have been 
executed, so you may not want them to execute again! Turn on the "debug" 
toolbar and use the "step over" and "step into" buttons.  Be aware that the 
"Continue" button (right-pointing triangle) will run from the point you're at 
right to the end.

"Simon" wrote:

> Hi there, I hope you can help, I am not VB literate unfortunately but I am 
> trying to run a macro with the following line of code which creates an error:
> 
> LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> 
> Is there a change between versions which means this line won't work any more?
> 
> 
> 
0
Utf
4/22/2010 9:25:01 AM
Kevryl,

I think it highly unlikely a macro would 'settle in' and learn to live with 
an error. You note you were working in 2007 and called another workbook using

Windows("Accounting.xls").Activate

If it was a 2007 workbook then that line will fail because of an incorrect 
file extension which should be

Windows("Accounting.xlsx").Activate

or another appropriate extension for the type of 2007 workbook
-- 
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that 
introduces the fewest assumptions while still sufficiently answering the 
question.


"Kevryl" wrote:

> Hi Simon, you've got me, being new to 2007 too. No doubt someone will soon 
> give you a definitive answer soon, but until then...
> 
> I had a problem running a macro that tripped on the line, 
> "Windows("Accounting.xls").Activate" which was merely to switch between 2 
> windows in the one instance of Excel. It tripped the first time giving an 
> error message, so I went into debugging, stepping over all the commands up to 
> that one and then "stepped into" from there. It found its way through without 
> an issue and then worked perfectly after that. So its possible that if you do 
> the same, yours too may "settle in" (OK, some Excel geek can ridicule the 
> terminology, but it worked ;-). )
> 
> Remember that any commands before the one that tripped will have been 
> executed, so you may not want them to execute again! Turn on the "debug" 
> toolbar and use the "step over" and "step into" buttons.  Be aware that the 
> "Continue" button (right-pointing triangle) will run from the point you're at 
> right to the end.
> 
> "Simon" wrote:
> 
> > Hi there, I hope you can help, I am not VB literate unfortunately but I am 
> > trying to run a macro with the following line of code which creates an error:
> > 
> > LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> > 
> > Is there a change between versions which means this line won't work any more?
> > 
> > 
> > 
0
Utf
4/22/2010 9:43:01 AM
This is a guess since you didn't say what error occurred.

xl2007 can open older versions of files in compatibility mode -- where the
number of rows is 64k (not 1 meg).

So depending on what workbook/worksheet is active, that unqualified Rows.count
could be 64k or 1Meg.

I'd qualify that range:

with Master_Wksht
   lastrow = .range("N" & .rows.count).end(xlup).row
end with



Simon wrote:
> 
> Hi there, I hope you can help, I am not VB literate unfortunately but I am
> trying to run a macro with the following line of code which creates an error:
> 
> LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> 
> Is there a change between versions which means this line won't work any more?

-- 

Dave Peterson
0
Dave
4/22/2010 12:05:34 PM
If the code fails when run at full speed but works when stepped through, 
all else being equal, it usually means Excel has some housekeeping to 
do, that it hasn't finished before the command.

Inserting a one-word line

DoEvents

before the line that shows the error will often give Excel a chance to 
do all that background stuff. Excel 2007 is more prone to this issue 
than 2003.

- Jon
-------
Jon Peltier
Peltier Technical Services, Inc.
http://peltiertech.com/


On 4/22/2010 5:25 AM, Kevryl wrote:
> Hi Simon, you've got me, being new to 2007 too. No doubt someone will soon
> give you a definitive answer soon, but until then...
>
> I had a problem running a macro that tripped on the line,
> "Windows("Accounting.xls").Activate" which was merely to switch between 2
> windows in the one instance of Excel. It tripped the first time giving an
> error message, so I went into debugging, stepping over all the commands up to
> that one and then "stepped into" from there. It found its way through without
> an issue and then worked perfectly after that. So its possible that if you do
> the same, yours too may "settle in" (OK, some Excel geek can ridicule the
> terminology, but it worked ;-). )
>
> Remember that any commands before the one that tripped will have been
> executed, so you may not want them to execute again! Turn on the "debug"
> toolbar and use the "step over" and "step into" buttons.  Be aware that the
> "Continue" button (right-pointing triangle) will run from the point you're at
> right to the end.
>
> "Simon" wrote:
>
>> Hi there, I hope you can help, I am not VB literate unfortunately but I am
>> trying to run a macro with the following line of code which creates an error:
>>
>> LastRow = Master_Wksht.Range("N"&  Rows.Count).End(xlup).Row
>>
>> Is there a change between versions which means this line won't work any more?
>>
>>
>>
0
Jon
4/22/2010 4:20:08 PM
G'day Mike,

I do understand your skepticism, but I've had similar where something has 
fouled up the first time but then "settled in". No, I can't explain it.

I'm still using the .xls format on these 2 files (save as 97-2003) as I'm 
not totally convinced yet that I want to stay with 2007. I did save an 
inventory file as .xlsm because from what I've read I thought I had to to 
preserve the macros, but that.s misleading because my macros work ok in .xls.

I was about to save the accounting files as a .xlsm too, but I re-thought 
that quickly because it wanted me to put an undersore in front of my 
range-names - a couple of hundred of them, many referred to in macros of 
which I also have dozens.

My decision now is whether to (A) stay with Win 7 Office 2007 and weather 
it, (hoping Office 2010 will address all the slow-down issues), or (B) roll 
back to XP & Office 2000, or (C) start a tedious switch to Linux (prob 
Ubuntu?) and Open Office.org and eventually become Microsoft independant.

Any thoughts on these choices would be appreciated. :-)



"Mike H" wrote:

> Kevryl,
> 
> I think it highly unlikely a macro would 'settle in' and learn to live with 
> an error. You note you were working in 2007 and called another workbook using
> 
> Windows("Accounting.xls").Activate
> 
> If it was a 2007 workbook then that line will fail because of an incorrect 
> file extension which should be
> 
> Windows("Accounting.xlsx").Activate
> 
> or another appropriate extension for the type of 2007 workbook
> -- 
> Mike
> 
> When competing hypotheses are otherwise equal, adopt the hypothesis that 
> introduces the fewest assumptions while still sufficiently answering the 
> question.
> 
> 
> "Kevryl" wrote:
> 
> > Hi Simon, you've got me, being new to 2007 too. No doubt someone will soon 
> > give you a definitive answer soon, but until then...
> > 
> > I had a problem running a macro that tripped on the line, 
> > "Windows("Accounting.xls").Activate" which was merely to switch between 2 
> > windows in the one instance of Excel. It tripped the first time giving an 
> > error message, so I went into debugging, stepping over all the commands up to 
> > that one and then "stepped into" from there. It found its way through without 
> > an issue and then worked perfectly after that. So its possible that if you do 
> > the same, yours too may "settle in" (OK, some Excel geek can ridicule the 
> > terminology, but it worked ;-). )
> > 
> > Remember that any commands before the one that tripped will have been 
> > executed, so you may not want them to execute again! Turn on the "debug" 
> > toolbar and use the "step over" and "step into" buttons.  Be aware that the 
> > "Continue" button (right-pointing triangle) will run from the point you're at 
> > right to the end.
> > 
> > "Simon" wrote:
> > 
> > > Hi there, I hope you can help, I am not VB literate unfortunately but I am 
> > > trying to run a macro with the following line of code which creates an error:
> > > 
> > > LastRow = Master_Wksht.Range("N" & Rows.Count).End(xlup).Row
> > > 
> > > Is there a change between versions which means this line won't work any more?
> > > 
> > > 
> > > 
0
Utf
4/23/2010 4:30:02 AM
Jon, thanks I'll try that next time I have a stall. :-)  DoEvents.... right 
got it.

"Jon Peltier" wrote:

> If the code fails when run at full speed but works when stepped through, 
> all else being equal, it usually means Excel has some housekeeping to 
> do, that it hasn't finished before the command.
> 
> Inserting a one-word line
> 
> DoEvents
> 
> before the line that shows the error will often give Excel a chance to 
> do all that background stuff. Excel 2007 is more prone to this issue 
> than 2003.
> 
> - Jon
> -------
> Jon Peltier
> Peltier Technical Services, Inc.
> http://peltiertech.com/
> 
> 
> On 4/22/2010 5:25 AM, Kevryl wrote:
> > Hi Simon, you've got me, being new to 2007 too. No doubt someone will soon
> > give you a definitive answer soon, but until then...
> >
> > I had a problem running a macro that tripped on the line,
> > "Windows("Accounting.xls").Activate" which was merely to switch between 2
> > windows in the one instance of Excel. It tripped the first time giving an
> > error message, so I went into debugging, stepping over all the commands up to
> > that one and then "stepped into" from there. It found its way through without
> > an issue and then worked perfectly after that. So its possible that if you do
> > the same, yours too may "settle in" (OK, some Excel geek can ridicule the
> > terminology, but it worked ;-). )
> >
> > Remember that any commands before the one that tripped will have been
> > executed, so you may not want them to execute again! Turn on the "debug"
> > toolbar and use the "step over" and "step into" buttons.  Be aware that the
> > "Continue" button (right-pointing triangle) will run from the point you're at
> > right to the end.
> >
> > "Simon" wrote:
> >
> >> Hi there, I hope you can help, I am not VB literate unfortunately but I am
> >> trying to run a macro with the following line of code which creates an error:
> >>
> >> LastRow = Master_Wksht.Range("N"&  Rows.Count).End(xlup).Row
> >>
> >> Is there a change between versions which means this line won't work any more?
> >>
> >>
> >>
> .
> 
0
Utf
4/23/2010 4:31:02 AM
Reply:

Similar Artilces:

Outlook 2003 keeps crashing #2
I get this message when I look in System information. Outlook keeps crashing quite often. I cannot for example delete two messages without outlook crashing. My colleagues do not have this problem. We are using the Microsoft mail exhange server. Faulting application outlook.exe, version 11.0.5510.0, stamp 3f1380f0, faulting module mso.dll, version 11.0.5606.0, stamp 3f334cce, debug? 0, fault address 0x003b6e16. Does anyone has a solution?=20 Best regards/ Bj=F6rn 1) I would definitely apply Service Pack 2for Office 2003 + applicable critical security updates. 2) Have you tried starting O...

Password Issue with MS Money 2003
Hello, I am not familiar with newsgroups but I hope it is a forum to seek assistance. I am unable to reach MS support via email from my home computer on this issue. My Money 2003 requires a net passport password to open my account in Money that I have successfully accessed for approximately 12 months. It does not recognize my password now. I have attempted several times with my existing password, changed my net passport password, even uninstalled and re- installed MS Money 2003 to gain access to my account. Nothing has worked. Each time it states I have failed to enter the corr...

Rollup 2 and Office 2007
I already have Roll Up 1 and the Office 2007 compatibility patch installed. If I now install roll up 2 will I have to reinstall the office 2007 compatibility? yes -- Regards, MS CRM Certified Professional http://microsoftcrm3.blogspot.com Chat with me on MSN / Gmail / Skype : ID Is :.. mscrmexpert@gmail.com "LLoyd" wrote: > I already have Roll Up 1 and the Office 2007 compatibility patch installed. > If I now install roll up 2 will I have to reinstall the office 2007 > compatibility? ...

Exchange 2003 new install can not receive external email.
I have just setup a new Windows Server 2003 standard edition with Exchange 2003 standard edition on it. I have been working for a while trying to get it to receive external email. I can send out and send/ receive internal messages, but when someone trys to send me a message from outside our network they get the following returned mail message This Message was undeliverable due to the following reason: Each of the following recipients was rejected by a remote mail server. The reasons given by the server are included to help you determine why each recipient was rejected. Recipient: <**...

Running average
Hi Guys, Been struggling a bit on this so a pointer would be great. Just a simple example would do.. tableA with two fields "Startdate" and "Amount" now i need a running average in the query which would give me the following output: [Startdate] - [amount] - [average] 1-1-2010 - 100 - 100 2-1-2010 - 50 - 75 3-1-2010 - 60 - 70 So in the average column the last value should be the average of the sum of the previous records and the current records (being the average of the total). I know that the fieldnames are...

Outlook 2003 and "Check Names"
Hi, We are testing Outlook 2003 at our office now and there is one very frustrating "feature" that is bugging all of us. When we create a new e-mail message and type in the first name of a person from the global address book and hit ctrl- k to check the name...we get a response that Outlook doesn't recognize the name and there are "no suggestions". The only way Check Name will successfully resolve the name is if we type it last name first (ie, Gates, Bill). This was not the case in Office XP or Outlook 2000. You could search by first name (or partial first name)...

Excel 2007
When I select cells to copy as a picture in Excel 2007, the resolution is terrible. Text and objects with shadow's are very blotchy when pasting the picture. How do you change the resolution of a 'Copy Picture'? ...

Create a distribution list from addresses in the 'To' list
Hi all, I belong to a social group, and our co-ordinator sends out an email from time to time with all the latest addresses in the To list. I already have a distribution list for the group, which then needs to be checked through and updated. Is there a simple way of transferring those addresses into my own distribution list? I'm using Outlook 2002. Everybody's fiddling around with bits of paper - I'll be a hero if I can make it easy for them! Thanks. Astley http://www.outlook-tips.net/archives/2004/20041105.htm -- Russ Valentine [MVP-Outlook] "Astley" <ast@...

Creating new attributes
When using Schema Manager to create new attributes, I'm not able to create a new attribute with "Lookup" as type, "Lookup" is not availabe as one of the type options. But yet some of the exist fields, for example, in Account table came with "Lookup" as type. Why? Is there a work-around? Please help. Thanks. You cannot add custom lookup's to the current release of MSCRM. The only way around is to build a custom .aspx page and build your own. Might be possible in the next release. "HEC" wrote: > When using Schema Manager to crea...

Personal Macro Workbook
I had some macro stored in the personal macro workbook but now I can not find the workbook. When I try to do a new macro and store it in the "Personal Macro Workbook" I get the error message "Personal Macro Workbook in the startup folder must stay open for recording". I click ok and get a message that I'm unable to record. I can record macro to other workbooks. What happened to the personal macro workbook ? Thanks ...

Install Exchange 2003 Server on new Hardware with same name
I got a new server to move my Exchange Server Installation. I want to keep the name I'm using now for my Server. Already read TechNet Article "How to Move Exchange Server 2003 to New Hardware and Keep the Same Server Name". Is there anything else that I should be aware of that is not on this TechNet article? I'm using a different Disk Configuration, does this matters? Should this be a smooth process? Thanks for any help you can give. The drive letters MUST match, because the paths of the databases are at the Active Directory. The disks can have different sizes than the or...

adding name /creating field/query?
Hello, I can create an invoice_number field in a query using the primary field ID from the main table as invoice_number: ID but if ID say is 100, I cannot work out how to create renewal_invoice_100 Cheers Geoff Geoff We aren't there. We can't see what you're looking at. Where did "renewal_invoice_100" come from and what does it mean? Please post the SQL statement of the query you are trying to use. -- Regards Jeff Boyce www.InformationFutures.net Microsoft Office/Access MVP http://mvp.support.microsoft.com/ Microsoft IT Academy Program Mentor http://micro...

Grammar check not working
Hello, I am using Word 2007 and have a problem with grammar and punctuation errors. I deliberately put two spaces between words, do not put space after a comma, write long sentences and finish a sentence without a verb but the green underline never appears. The spell check is functioning properly, no problem with that. In Word Options > Proofing, "Mark grammar errors as you type" is selected. I changed that selection and tried again but it still did not work. I used different languages as default language but no change. I would be grateful if someone could come...

Addressing within Exchange 2003
We are running Exchange 2003 SP2. We setup an MX record for a external email(alumni.cup.edu) these mailboxes do not exist within our exchange org. But when we send email to these externals email mailboxes we are getting the following NDRs: #5.5.0 smtp;550 Mailbox unavailable. #5.4.0 Is there a way in exchange to ignore these email address so that we don't get the NDR from within our Exchange Org? On Fri, 4 Aug 2006 08:08:02 -0700, Sabo, Eric <sabo_e@cup.edu> wrote: >We are running Exchange 2003 SP2. We setup an MX record for a external >email(alumni.cup.edu...

how do i add "Software Digrams" Folder in my Visio 2003
how do i add software diags folder in visio 2003 version. Like if i go to File->New it shows folders like brainstorming, project schedule, block diagrams but in my case its missing the Software Diags folder which contains activity diags, web mock ups, use case diags etc. please let me know how to get that template. thanks. Ankur What edition of Visio are you using? Check by going to the About Microsoft Office Visio dialog from the Help menu. "Ankur" <Ankur@discussions.microsoft.com> wrote in message news:F0D10BF0-A059-4A9C-B615-B99F3916F4E5@microsoft.com... > how...

Radar chart in Access 2007 report
Can you add a Radar chart to an access 2207 report? ...

How to change font size on formula bar in Excell 2007
I don't find Tools>Options>General (as suggested in other post answers) in Excel 2007. On the Office button there is an Excel Options but it doesn't provide a method of changing font size on the office but. My font is so small I can barely see it. Office button>ExcelOptions>Popular tab>in the "When creating new workbooks" section, choose font and font size -- Kind regards, Niek Otten Microsoft MVP - Excel "jimwillie" <jimwillie@discussions.microsoft.com> wrote in message news:588AAC05-0F52-404E-AA01-128E70E02D0B@microso...

Outlook 2003
Hello, we have one client pc with Outlook 2003 where the following problem occurs: if a mail is replied from a user created sub folder of the inbox, the reply will not appear in sent mails, but will end up in the same sub folder, sender and recipient appear as identical. The mail goes out properly though, it's just that Outlook sets internally sender = recipient and bounces the reply back to the subfolder in which the original mail is stored. This happens on a Win 2000 machine with SP4 and all updates, the other clients use Outlook 2000 or XP and there is no such problem. There are no ru...

[Exchange 2003] Mail enabled public folder and sender address
I have a Windows 2003 domain with a native mode Exchange 2003 organization; there are some mail enabled public folders. When a user replies to a message in a public folder, the outgoing mail's sender address is the user's one; I want it to be the public folder's one, or at least I'd like the "reply-to" address to be set to the public folder's. How can I accomplish this? Thanks Massimo You would need to grant the user permissions to be able to Send As the public folder. By default, when you reply to a message that is in a PF, the PF is not composing the ...

How do I create several NEW templates from start to finish please?
Hi knowledgeable people. I am looking for instructions on how to create a range of basic templates that I can use, perhaps even by selecting them as 'stationery', for example; if I go to >New >Format >Apply stationery, or any other similar method. I can create new html stationery backgrounds, but this is NOT what I am looking for, as a lot of people still read email in plain text only...does this make sense? Plain text templates would be fine. I simply can't find any info on creating email templates anywhere to suit this Windows Live Mail Desktop versio...

Import from Eudora 6 to Outlook 2003
I am trying to import messages from Eudora 6 to Outlook 2003. I am receiving the error message "The mail folder could not be opened. If another application is using this file, please close and try again. No other applications are running Thanks for any help see article 257354 of the microsoft knowledge base on http://support.microsoft.com: "Outlook Cannot Import Eudora Messages When Eudora Mail Is Stored in a Non-Default Location" ciaos >-----Original Message----- >I am trying to import messages from Eudora 6 to Outlook 2003. I am receiving the error message ...

Reverse created rules
I inadvertantly created a rule to automatically send emails from an email address directly into the deleted files. How do I reverse or delete the rule for this sender??????? If this is Outlook then select the Tools Menu > Rules Wizard > locate the Rule and delete it, if its Outlook Express then go to Tools > Message Rules "joebzii@everestkc.net" <anonymous@discussions.microsoft.com> wrote in message news:1c12401c4218b$fa8e7f70$a401280a@phx.gbl... > I inadvertantly created a rule to automatically send > emails from an email address directly into the deleted &...

keyboard shortcut in addin macro
How do you assign a keyboard shortcut or a custom button to run a macro which is in an addin. These macros dont appear on the macro list Thanks -- Patrick Hi have a look at the OnKey method in the VBA help -- Regards Frank Kabel Frankfurt, Germany "Patrick" <Patrick@discussions.microsoft.com> schrieb im Newsbeitrag news:FBEB937C-C3FC-47BB-8E8A-EE0BBCB14DFB@microsoft.com... > How do you assign a keyboard shortcut or a custom button to run a macro which > is in an addin. > > These macros dont appear on the macro list > > Thanks > -- > Patrick Patr...

Office 2003, Outlook (Outlook Today)...
OK, this is driving me nuts. I note that w' 2003 (and XP (2002)?) the default install sets the startup folder to the Inbox. IIRC, one of the earlier Offices installed Outlook to startup w' that "all in one view" - Outlook Today. So just as a wee test - I thought I'd try that for a while, and indeed I found it quite handy to be able to see all pertinent data on the one screen. *However* (and I'm wondering if this is the case with others), I *HAVE* to use my mouse, whenever I switch to the Inbox, or Calendar, or Tasks to get the damn focus onto a 'sujbect&...

Exchange 2007 across account search
Does Exchange 2007 has an option to search all users mail for keywords? That all SBS workgroup users can search for messages to/from all other users. Is there any advanced indexing system to speed up search results? Thanks! On Tue, 26 Jan 2010 14:22:12 +0200, "Ronald" <2omikk@gmail.com> wrote: >Does Exchange 2007 has an option to search all users mail for keywords? >That all SBS workgroup users can search for messages to/from all other >users. >Is there any advanced indexing system to speed up search results? > >Thanks! > Bunch of ...