Selecting Multiple Worksheets - Sort All
Mar 14, 2012
The code im using all worksheets. How do I make this sort all but the first
For Each WS In ActiveWorkbook.Worksheets
If WS.Name "Sheet1" Then
Range("A1:X2270").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
View 1 Replies
ADVERTISEMENT
Oct 9, 2009
I would like to use a macro to sort multiple worksheets simultaneously. I need to sort on last name (column A) then first name (column B) and my data does not start until the 8th row (A8:AF8). The data range should be the same for all worksheets that I need to sort. I found the code below here on ozgrid (Dynamic Sort Across Multiple Sheets) but I'm not sure if its appropriate or the best way to customize it so that the 1. Can sort on two criteria
2. Is specified to nonblank cells in a specific range, A8:AF8 and below
Sub DynaSort()
Dim wsSheet As Worksheet
For Each wsSheet In Worksheets
Select Case wsSheet.CodeName
Case "Sheet1", "Sheet2", "Sheet3", "Sheet4"
With wsSheet
.UsedRange.Sort Key1:=. Range("B14"), Order1:=xlAscending, Header:=xlYes
End With
Case Else
'Nothing
End Select
Next wsSheet
End Sub
View 9 Replies
View Related
Aug 16, 2006
I am using the code below to transfer data from a single sheet to approx'
200 sheets. These sheets are staff training sheets, one per staff member.
This code works great. What I would like to know is, is there a way to then sort the data on these sheets in decending order? I have tried on sheet change but this seems to stop the transfer to other pages.
Sub Tranfser()
Dim shtTemp As Worksheet
Dim lngOutRow As Long
Dim rngData As Range
For Each rngData In Range("A5", Range("A5").End(xlDown))
Set shtTemp = GetWorksheet(rngData.Offset(0, 1).Value)
If Not shtTemp Is Nothing Then ..........................
View 9 Replies
View Related
Dec 14, 2006
We are trying to sort a spreadsheet by the data in column I. This column refers to a state. I need help creating a macro that can sort column I so that different states go into different worksheets.
States ME, NH, MA, RI, CT, VT go to a worksheet titled 357899, states NY, NJ would go into worksheet 351835, states MI, IN, OH would go into worksheet 351857, and everything else would go into worksheet 351836. The main data worksheet where the info is being sorted from is named All_Accounts. Column I has a header labeled State, so data actually starts in Row 2. I need the full rows copied to the new worksheets while leaving the main All_Accounts worksheet in tact.
View 9 Replies
View Related
Feb 26, 2014
I found the code below on the Microsoft website and it works except it didn't treat the worksheet tabs as numbers so the sort is 1, 10, 100, 101 etc.
How can I get it to treat the worksheet values like numbers and sort accordingly?.
Code:
Sub Sort_Active_Book()
Dim i As Integer
Dim j As Integer
Dim iAnswer As VbMsgBoxResult
'
' Prompt the user as which direction they wish to
' sort the worksheets.
'
[Code]....
' If the answer is No, then sort in descending order.
'
ElseIf iAnswer = vbNo Then
If UCase$(Sheets(j).Name) < UCase$(Sheets(j + 1).Name) Then
Sheets(j).Move After:=Sheets(j + 1)
End If
End If
Next j
Next i
End Sub
View 1 Replies
View Related
May 2, 2008
I have been asked to create an attendance worksheet where employee names and data are entered on a "main" worksheet and hours are entered on monthly worksheets. The names on the monthly worksheets are referenced from the main worksheet. Therefore, if I add a name and do a sort, the names on all pages will move, but the data will not. I imagine I will need an ID column to help sort. How do I make a macro to do the sort?
View 2 Replies
View Related
Apr 26, 2006
How do I modify this macro so that the worksheet array will select all the worksheets except sheet 1?? My workbooks will have varying numbers of worksheets ...
View 3 Replies
View Related
May 30, 2012
As of right now these are the steps i do to sort...i click custom sort choose My data has headers and then i select from the drop down list the word FRNAME.
is there any way i can setup a macro to do this for me? i tried recording the macro but it just is recording me choosing the column FRNAME is in. This does not work for me since FRNAME end up being in different columns all the time but will always be in row 1.
View 1 Replies
View Related
May 15, 2013
I have read that there is a VBA macro in F11, but I also read that it would only sort the workshhet names, but not the data. I have Excel 2010.
View 2 Replies
View Related
Jul 16, 2007
I am currently working on a simple macro to help with formatting a spreadsheet. The number of tabs on the spreadsheet will change to reflect the number of companies I'm running reports for. But the same process is to be applied to each tab. The issue I'm facing is I don't know the appropriate code to select all tabs without specifically referencing them.
The code that I would like to apply to all tabs is as follows:
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$85"
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
View 9 Replies
View Related
Mar 21, 2008
I recorded the following macro to select all the worksheets in the Activeworkbook by clicking on the first worksheet and then hitting Shift Tab and selecting the final worksheet (thus '[Group] selecting' all worksheets in the active workbook).
Sub Macro1()
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
Sheets("Sheet1").Activate
Range("A1:B2").Select
End Sub
How do you generalise the Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select if the number and names of worksheets varies from workbook to workbook?
View 9 Replies
View Related
Aug 22, 2014
I want to make a range variable ("testrange") that I can use to define a range of non-continuous cells and then use that range variable to select that range of cells in different worksheets within the same workbook.
I tried the below code (simply coloring cells red), but get an error when I try to select "testrange" after moving to the next worksheet.
[Code] .....
The next worksheet is also supposed to have the same range of cells colored red, but I can only get it to work on the first active sheet.
I would like to avoid having to repeatedly rebuild the range I want selected each time I move to a different worksheet.
View 7 Replies
View Related
Mar 19, 2012
I have below code which I was thinking is very simple to select variable worksheets. However I get Debug error when running:
Code:
Dim rng As Range
Dim cl
Set rng = Sheets("Budgetted sku's").Range("A2:A24")
For Each cl In rng
Sheets(cl.Value).Select
Next cl
View 5 Replies
View Related
Jul 12, 2012
I have a workbook with 3 worksheets which contains a single spreadsheet where the user enters data and 2 worksheets containing all the named ranges and formulas(divided up by product model) used on the data entry worksheet. What I've been trying to accomplish is to choose one worksheet based on which product model I select on the data sheet.
View 1 Replies
View Related
May 14, 2012
I have 2 nearly identical workbooks and I need to update historical data from the old workbook into the newer one.
My current Coding Snippets that I want to use look like the following:
Code:
Sub UpdateWorkbook()
Dim ws As Worksheet
Dim r1 As String
Dim r2 As String
Dim r3 As String
Dim r4 As String
Dim r5 As String
Dim r6 As String
[code]....
Now, this code isn't working I suspect because the Copy and PasteSpecial Functions don't work the way I wish to.
View 4 Replies
View Related
Aug 30, 2007
I have a workbook with MANY worksheets. The first 17 are static, as well as the 18th sheet on to the end,but there can be many sheets added in between sheets 17 and 18 (up to 56 added) all named Origin 1, Origin 2....Origin 56. Users can add these sheets in any order as many times as they want, but eventually the order of the sheets will not be in ascending order. I wanted to know how to organize the sheets in order of Origin 1, Origin 2, Origin 3, etc after the user adds new sheets with the macro. I can find out how to add it to my current module on my own.
View 5 Replies
View Related
Apr 17, 2014
I need to sort out 4 columns D,B,A,L in ascending order for 5 different worksheets from range A7 to BW.
The sorting start at row 7. I have created a VBA code but got error.
View 9 Replies
View Related
May 7, 2009
Is it possible to sort numerous worksheets based off a list of cells that are the names of the worksheets within the same file? For example my worksheet names are:
YTD Texas
YTD Florida
Period Texas
Period Florida
I can sort the sheets by alpha but it puts the two YTD worksheets together when I need the two Texas sheets side by side (I need this on a file that contains over 100 worksheets otherwise I would do it manually) I was wondering if I could create my order of sheet name in another worksheet and reference that list through vba code?
View 7 Replies
View Related
Jul 22, 2006
I want to loop through all worksheets and sort all columns in each worksheet. Here is what I have, but for some reasson, it only sort the first sheet. Any suggestions?
Sub test2()
Dim ws As Worksheet
For Each ws In Worksheets
Cells.Select
Selection.Sort Key1:=Range("E1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next
End Sub
View 4 Replies
View Related
Sep 22, 2007
I have a worksheet of about 75000 rows so I have to use 2 worksheets. I want to sort the data in column A in ascending order so I want to start at 4999 until whatever number happens to be in row 65536 then continue sorting the next highest number in another sheet. I tried using this but it didn't work: ..
View 2 Replies
View Related
May 16, 2014
I am trying to sort information on my worksheets by date, oldest to newest however this does seem to be working on the workbook i have attached.
View 3 Replies
View Related
Oct 7, 2011
I have the below code that sorts a list of Doors that I have in row C17 downwards. Door 54, Door 7, Door 109 etc. The list is feeding a drop down box, people find the door they were looking for, in the said drop down box.
Code:
Sub ListSorter()
Dim LastRow As Long
LastRow = Range("C" & Rows.Count).End(xlUp).row
[Code]....
I wondered if there was some code I could add to the end of this, that would the sort worksheets, which are all named after each cell in the list, in the same order.
View 3 Replies
View Related
Oct 8, 2008
code to sort all the worksheets in a workbook...
View 13 Replies
View Related
Aug 21, 2008
It sorts the ActiveSheet, but none of the other sheets and there's no runtime error. I am using this on a test workbook with the same data in 5 worksheets.
What's wrong with this code?
Sub SortSheets()
Dim ws As Worksheet
For Each ws In Worksheets
Cells.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next ws
End Sub
This looping structure works for PageSetUp, but not this Sort.
View 5 Replies
View Related
Aug 29, 2006
Is it possible to keep the sort icon available on a worksheet which is protected? I have issued a spreadsheet to colleagues which contains formulas so I have protected it, but I have now been informed that they need to be able to sort the data according to a ref number.
I thought of using code (which I'm not very good at) and used some from another excel document, but couldn't get it to work...the code was ....
View 9 Replies
View Related
Oct 11, 2007
I am trying to sort worksheets in excel by numerical order. I have renamed each worksheet with a different zipcode that corresponds to data on that sheet.
I believe there might be two ways to do this,
1) by sorting numerically the worksheet names.
2) by perhaps referencing a cell on each worksheet (i.e. the zipcode) and sorting it that way.
View 7 Replies
View Related
Jan 6, 2009
I'm currently doing a survey using an excel workbook that contains multiple questions across multiple worksheets using radio buttons linked to certain cells.
I have around 400 workbooks coming back to me, so what i want to do is take specific values from across many worksheets within each workbook and combine them into a large master table in a seperate workbook.
I've tried using VBA, but not being very proficient at it i've hit a brick wall with that, so i'm hoping that there is an easier way to do it than what i'm currently pursuing.
View 9 Replies
View Related
Dec 23, 2008
I am trying to select multiple rows so that i can sort. The code i have
View 2 Replies
View Related
May 31, 2014
I am trying to copy rows to a new sheet that meet a couple of conditions.
They have to meet condition 1, 2, or 3 and conditions 4, 5 and 6. Meaning have any of those search terms listed in columns L, M, N columns, but no terms in columns I, J, or, K.
Sub filter_data()
Dim rng As Range
Dim header_pos As Integer
[Code]....
View 2 Replies
View Related
Jun 18, 2007
I need to select the record that has the highest number in column C by using an input value like (red).
desired Result : red, gt3, 100
A..............B...............C
red..........rt2.............12
green.......rt3..............4
red..........st2..............33
blue.........st4.............45
green.......st1.............44
red..........gt1............100
blue.........ft4..............85
Is it some variation of the MAX function?
View 9 Replies
View Related