473,503 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual basic sort on active sheet

1 New Member
I want to run a sort on the active sheet regardless of what sheet is active. How do I rewrite the following without a sheet name so that it will just run on the sheet that is active when the macro is called to run. I want to get rid of "Master Daily calc" and have the macro just run on the sheet that is active at the time.

Expand|Select|Wrap|Line Numbers
  1. Range("B5:E37").Select
  2.     ActiveWorkbook.Worksheets("Master Daily calc").Sort.SortFields.Clear
  3.     ActiveWorkbook.Worksheets("Master Daily calc").Sort.SortFields.Add Key:=Range _
  4.         ("B5:B37"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
  5.         xlSortNormal
  6.     With ActiveWorkbook.Worksheets("Master Daily calc").Sort
  7.         .SetRange Range("B4:E37")
  8.         .Header = xlYes
  9.         .MatchCase = False
  10.         .Orientation = xlTopToBottom
  11.         .SortMethod = xlPinYin
  12.         .Apply
  13.     End With
Jun 21 '13 #1
2 3964
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code.

Your thread has been moved to the Access forum.

Use ActiveSheet.
Jun 21 '13 #2
Mihail
759 Contributor
Replace "Master Daily calc" with this: ActiveSheet.Name
Jun 21 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3195
by: Lucas Raab | last post by:
Can I use Python as an extension language to Visual Basic sort of like in C or C++?
2
2091
by: janice_2k | last post by:
Dear Sir/Mdm, I am writing this on behalf of my company. We bought the Visual Studio .NET Enterprise version but currently we need to use Visual Basic 6 for a small development. We are not able to...
2
5572
by: Marcel | last post by:
Hi, I'm using Microsoft Visual Basic .NET and want to reference the ThisApplication variable but cannot get to it or find the OfficeCodeBehind class. Is this a shortcomming of the fact that I...
3
2943
by: Omar | last post by:
Hi Developers, I am trying to access an Excel data file through a VB.Net application. I have the following code: =================================== VB.Net Code =================== Dim...
4
4831
by: Amaryllis | last post by:
Hi, I am working on a Windows application that will read through an excel spreadsheet of unknown size and upload the information to a file on AS/400. I have installed the PIAs needed to connect...
0
1661
by: campeon | last post by:
Hello,, I don,t understand bery good the visual basic or excel i dowload a good time activities program from a web site the program is like a cronometer whit start button and stop button...
1
1262
by: pauloetiago | last post by:
Hello!! We are Paulo and Tiago, two portugueses students. We need to create an application which connect the Visual Basic and the Active Directory. Can you help us in that work? We need the code...
8
2843
by: Chris Asaipillai | last post by:
Hi there I have some questions for those experienced Visual Basic 6 programmers out there who have made the transition from VB6 to Vb.net. How long did it take you to learn at least the basic...
10
3096
by: Esmael | last post by:
Hi to all, /*****************************/ OS-WIn XP SP2 VB6 SP6 /*****************************/ Is their anyone who can help me with this: Source code written on VB6.
0
1242
by: David Blanco | last post by:
Hi, I would like to know kow to set "Pages Per Sheet" programmatically for "N-Up" Printing in visual basic 6. I've a lot of code in C, but I need to write it in vb6. I've played a lot with...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.