Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 06-21-2012, 01:54 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline Sorting Challenge Windows 7 32bit Sorting Challenge Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Okay, you've slightly misunderstood my quesiton. Let me explain what I was driving at....

In my example I used
Code:
With Sheet1
Sheet1 is the codename of the worksheet in the attachment you gave in post #1. So my code is doing stuff with Sheet1. It understands what Sheet1 is so the code runs fine.

In your code you used this instead:
Code:
   With Data
Data isn't anything - it's just a word (a variable) which you've put in your code. You're getting an error message because it doesn't know what Data is. Your code needs to explain which worksheet the sort should be happening on. To put it slightly more technically: you don't have variable declaration enforced (with an Option Explicit statement) so when the compiler scans your code it creates a Variant variable called Data with holds a value of Empty.


So you need to either use the worksheet's codename like I did (you can see the codename in the VBA IDE in the project explorer window - see my attachment) or you need to get a reference to the worksheet via the Worksheets collection using either the worksheet's name or it's index (eg With Worksheets("Data"). Does that make sense?
Attached Images
File Type: jpg Codename vs Name.jpg (84.3 KB, 14 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting by certain criteria randenius Excel 2 06-11-2012 02:18 AM
Sorting Challenge Word Challenge jpotter2 Word 3 03-22-2011 02:07 PM
Challenge!! Need help though. (Conditional formatting) knuckles70 Excel 2 02-05-2010 12:24 PM
Sorting Challenge CHALLENGE! Issue sorting data containing relative references on a separate tab lax828 Excel 3 01-07-2010 11:28 AM
Challenge: Get Custom Form to Show up in Reader Pane in 2007 JohnGG Outlook 0 08-21-2009 05:44 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:15 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft