Select / Format Multiple Sheets
Dec 13, 2011
I am trying to use VBA to select all sheets and then format
Wrap Text
Freeze at A2
Column Widths
I tried the following code but it is just formatting one sheet.
Sheets(Array("New", "Closed", "Open", "Open_Beg_Month", "Closed WAD")).Select
Range("A2").Select
ActiveWindow.FreezePanes = True
View 2 Replies
ADVERTISEMENT
Feb 26, 2012
I have a workbook that updates from external source and creates sheets depending on a cell range.
I have put tab 1 and tab 0 on either end of where the new sheets will be inputted, will never know how many sheets
What i need to happen is if someone fills in "complete" in A7 in my "summary" sheet then the values in row 6 in all the other sheets get hardcoded. This needs to happen from A7 down to A26, so A8 = complete then copy row 7 etc
This is what i have so far
I get compile error here ........Sheets(ArrSh(1)).Activate
Also need it to work for all the other rows.
Sub hardcode()
'
'Sheets("Summary"). Select
If Range("a7") = "complete" Then
'
Sheets(Array("1", "0")).Select
Sheets(ArrSh(1)).Activate
[Code] ......
View 2 Replies
View Related
Apr 14, 2014
I'm trying to select multiple sheets and print them out. At this time the code is only printing out the "Work Order" sheet. I'm guessing it's something to do with the PrintOut command trying to print the active sheet and not the array?
Code:
Sheets(Array("Work Order", "Timesheet", "Communications")).Select
Sheets("Work Order").Activate
ActiveSheet.PrintOut Copies:=1, Collate:=True
I have also tried the following but it just prints out every page in the workbook.
Code:
Sheets(Array("Work Order", "Timesheet", "Communications")).Select
Sheets("Work Order").Activate
Sheets.PrintOut Copies:=1, Collate:=True
I've also tried the PIDOOMA approach with this and failed
Code:
Dim TechnicianPack As Variant
TechnicianPack = Sheets(Array("Work Order", "Timesheet", "Communications")).Select
Sheets("Work Order").Activate
TechnicianPack.PrintOut Copies:=1, Collate:=True
View 7 Replies
View Related
Oct 24, 2008
File attached to show problem
How do I select all the sheets that are Marked Y in column B when the button is clicked?
View 11 Replies
View Related
May 10, 2014
I would like to select say 2 id from sheet1 and 2 names from sheet 2 randomly and copy to sheet3, to cells a and b,have seen various codes but none seem to fit the bill.
View 3 Replies
View Related
Jan 22, 2010
I have 14 worksheets in a workbook.
All sheets are identical in that they have the same headings within the same range.
I want to apply formatting (bold some text, apply borders, center, etc.), but to all the sheets at once. I know I can do this with a simple loop, but I was wondering if there is a more efficient way of doing it.
I've been playing with
sheet( array(sheet1.name, sheet2.name))
I don't think I have correct syntax or use using the the above.
I tried coding what I would do if I was performing this manually, which is to select all the sheets and apply the formatting to sheet1. Then all the sheets would have the formatting.
View 9 Replies
View Related
Oct 23, 2013
I am having trouble getting the selection of sheets to work. I have a workbook that has multiple sheets and one constant sheet (Summary). There is code to create new forms in this workbook and insert them after the Summary sheet. These forms all have a date input that is formatted as a date (mm/dd/yyyy), these dates get modified on the day the form is created, there may be any number of sheets created during this process. I have to print the summary sheet and only the newest forms created. I need a code to select sheets to print based on the date input of a user for each form. This is what I have so far:
VB:
Dim i As Variant
i = Range("B5").Value >= InputBox("What date to start PDF from? Format = mm/dd/yyyy")
Sheets(Array("i")).Select [code]....
If the dim can be taken out and just included in the line for the array that would be fine with me. The cell "B5" is where the date is located in each form. I want to input a date and the macro will select the sheets where the date is equal to and greater than the date entered. The Summary sheet will always be included in the print set. I have a dialog box for setting which printer to use - this file will be used at different offices and therefor the printers will be different and it will also allow to create a PDF if desired.
View 9 Replies
View Related
May 18, 2006
How can I select sheets in a workbook based on the premise that the sheetname does not have the letter "Q" in it? New to forum, so apologies if format is not kosher.
I have a group of 50+ workbooks which are all set up in the following format:
-Contains 30+ sheets.
-Sheet names are varied, but follow a pattern. I try to keep the sheet names consistant on all workbooks so that it is easier to reference, but other users make this impossible.
-However, I managed to keep two things consistant: There are two categories of sheets. In one group all sheetnames have a "Q" in them and in the other group all sheetnames DON'T have a "Q" in them.
Here is my problem: I need to run a macro to perform retative tasks on the GROUP OF SHEETS WITHOUT A "Q". To begin the macro I need to select these sheets and copy them to a new workbook, but since the actual sheetnames are varied, I am having trouble coming up with a flexible way of selecting sheets. The closest I have come is using a IF ... LIKE ... THEN statement, but I can only get it to work to select the sheets with a "Q" in the name and not the opposite.
View 2 Replies
View Related
Jun 13, 2007
I'm trying to write a macro to select all the Sheets in a Workbook, and set some properties [Auto ColumnWidths, Landscape, and Fit to 1 page wide] for all of them.
I don't know the names of the sheets, nor how many there will be - this part is tagged on the end of a long macro that creates new files and pastes various data into them. The code below only seems to work on the Active sheet - not any of the others selected. Curiously, I can set a specific column width for all sheets, but not Auto Widths.
With ActiveWorkbook
Sheets.Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End With
Sheets.Select
ActiveWindow.Zoom = 80 ' This line works!
Cells.Select
Selection.RowHeight = 13.5
Selection.EntireColumn.AutoFit
Columns("C:C").Select
Selection.ColumnWidth = 34 ' This line works
Range("A1").Select
View 2 Replies
View Related
Jun 21, 2012
Currently, I have 65536 rows of data per sheet in an excel file. I have a total of 8 sheets. I need to combine all these sheets into one csv file. As my company uses excel 2003, I can't consolidate all sheets into 1 sheet before saving as CSV format as it will exceed the number of rows available in excel 2003.
However, the number of rows and number of sheets in the excel file will change monthly, and I need to consolidate the excel file accordingly.
I am wondering if I could save a new workbook as csv format first before copy and paste all data into that csv file.
Also, all the 8 tabs have the same header. I only need to copy the header on the first tab, and for the sequence tab, I will only need to copy row 2 onwards.
I have recorded a macro based on a sample data.
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveWorkbook.SaveAs Filename:= _
"C:Documents and Settingse31425My DocumentsBook1.csv", _
FileFormat:=xlCSV, CreateBackup:=False
[Code] .......
View 1 Replies
View Related
Jan 12, 2014
I have a workbook that contains something like 50 worksheets and they all contain data with the same columns, for example column A is Project, column B is Project Name, etc. I need to convert data in each worksheet into an Excel Table. There has to be an easier way than manually converting each worksheet into a Table. However, when I group all of the sheets, the option to Insert a Table is not available even though the data starts in the same row and contains the same number of active columns in each worksheet. Is there an easier waty to insert a table in all of the worksheet simultaneously?
View 2 Replies
View Related
May 1, 2008
I've seen a few threads on here about this issue but none of them do quite what I am looking for. I'd like for a single page "report" to be created when a user presses a button (which runs a macro, of course) The macro should be able to run through certain named sheets (even if hidden) and if a cell in any row is red within a sheet then the entire row or rows that meet the criteria should be copied and pasted into the Report sheet.
On the report sheet, for each sheet that has had rows that were copied, I'd like to have the name of the sheet as the header above the pasted rows so that the user knows which sheet the data came from. Any sheet that doesn't have red cells would be excluded from the report. I've attached a sample file but had to limit the number of sheets because of Orgrid's file size limit. Hopefully, you'll see what I am getting at here.
View 8 Replies
View Related
Apr 29, 2009
This piece of code is run from a form when the user click OK. It dumps the data the user filled in on the form, below the last row on the sheet.
View 2 Replies
View Related
Feb 8, 2008
I know how to use .sheetscount to loop through all sheets in a work book, but what is the syntax to select all sheets?
View 9 Replies
View Related
Sep 15, 2006
Is there any way to select the last Worksheet, other than clicking on the
Last Tab?
Because i created a macro which inserts more sheets after the Last Sheet,
but that Last Sheet is named (lets call it LS), so everytime the macro runs
it inserts new sheets after the LS sheet, rather than the 'real' last sheets.
View 9 Replies
View Related
Oct 7, 2009
In a worksheet, I have a listing of people. In a different sheet, I have a list of trips. I want to be able to select a person (a right-click, function), then move to the other sheet, find the desired trip and, double-clicking, select that trip to be associated with the selected person. Those two data elements would be written to another sheet. I can select the person and switch to my listing of trips. I can double-click on the desired trip. But I can't figure out how to join the two and write the data.
View 5 Replies
View Related
Mar 22, 2012
I have a list of worksheets that I want to select from a list.
Region 1
Region 2
Region 3
etc....
These sheets are in a workbook that contains other non Region sheets.
How do I select all of them without hardcoding the sheet names?
View 5 Replies
View Related
Oct 11, 2012
I want to have a macro that selects all sheets that end in " dump". The sheets are not next to each other. This is what I currently have, but I would like to make it dynamic.
Code:
Sub SelectDumpSheets()
Sheets(Array("sheet1 dump", "sheet2 dump", "sheet3 dump", "sheet4 dump", _
"sheet5 dump", "sheet6 dump", "sheet7 dump", "sheet8 dump", _
"sheet9 dump", "sheet10 dump", "sheet11 dump", "sheet12 dump", _
"sheet13 dump", "sheet14 dump", "sheet15 dump", "sheet16 dump", _
"sheet17 dump", "sheet18 dump", "sheet19 dump", "sheet20 dump", _
"sheet21 dump", "sheet22 dump", "sheet23 dump", "sheet24 dump", _
"sheet25 dump", "sheet26 dump", "sheet27 dump", "sheet28 dump")).Select
End Sub
View 4 Replies
View Related
Aug 22, 2007
I have a File with many sheets (40 - 60) and I'm trying to eliminate the sheets I don't want. The names of the sheets are all random, but in common they have a three letter code for a country.
The following is the code that I have -
Sub Deletesheets()
Dim x As Integer
Application.ScreenUpdating = 0
On Error Resume Next
For x = 1 To Sheets.Count
Sheets(x).Select
I'm hoping to save any sheet that has either CAN or USA the name and delete the rest.
Besides being inefficient, my code errors out because I've got my IF's and ELSE in the wrong place, but I can finagle it to work.
View 9 Replies
View Related
Apr 29, 2009
I've been trying to work out a macro that will select all sheets in a workbook, except the first sheet (called Summary), then delete them.
This is what I've got:
Sub SelectAllSheets()
Dim mySheet As Object
For Each mySheet In Sheets
With mySheet
If .Visible = True Then .Select Replace:=False
End With
Next mySheet
End Sub
What do I need to add to it to ensure it doesn't select the first sheet (called Summary) and then delete all the others?
View 9 Replies
View Related
May 2, 2006
I've put the following code together;
Sub RemoveStars()
Application. ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("Sheet1").Select
Cells.Replace What:=" *** ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Sheets("Sheet2").Select
Cells.Replace What:=" *** ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Sheets("Summary").Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
There are more sheets that this is run on, but I am sure you get the idea. I guess that this can be done using a loop, I would prefer to code the sheet names in, there are 5 in total.
View 6 Replies
View Related
Aug 9, 2007
I have been running a simulation for about 18 hours now and just received:
Run-time error '1004':
Method 'Add' of object ' Sheets' failed
I have been creating new sheets, importing data, pulling some values from the data then deleting the respective sheet. I am using:
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
The sheet is actually being added to the workbook, seemingly before the error. I resume the code, and a new sheet is placed in the workbook and it errors again. The Debugger stops and highlights on the code above.The sheet count number was 10895 at the error, just as an indicator of how many times the simulation has performed successfully. I am hoping this is something I can fix without having to start over...
View 9 Replies
View Related
Jan 19, 2013
user form that has a list box that only picks up visual worksheet (not hidden ones) and then allows the user to select which ones to print via check boxes.
View 5 Replies
View Related
Mar 29, 2014
How to select all sheets except the 4 sheets to be excluded using macro. i want to select worksheet with a macro except sheet name
"sheet1"~"sheet4",
View 1 Replies
View Related
Apr 4, 2014
I hava a macro-routine in my workbook: "SwitchBoard.xlsm"
The macro opens a workbook: "OriginalFile.xlsx"
When OriginalFile.xlsx is opened I will select some of the sheets in this opened book, let the macro copy them into "SwitchBoard.xlsm" as new sheets before the macro proceeds and "do stuff" after they are renamed (I have a routine for this renaming.)
How do I programme this temporary macro-pause/stop-proceed when I manually select the sheets I will copy for further use in SwitchBoard.xlsm?
View 2 Replies
View Related
Mar 2, 2008
Does anyone know the keyboard shortcut to select all sheets.. without creating a macro?
View 9 Replies
View Related
Aug 29, 2006
Can someone please help? I am very new to vba but I have managed to write code ( multiple subs strung together with Call statements) for about 25 sheets in this one workbook. Each sheet has a command button that initiates the data maipulation that I want to accomplish on that particular sheet. It all works very well when I go to each sheet and click on the command button.
Now I want to make all of these processes run from one command button on the first sheet. All of the subs on every sheet now have unique names because I anticipated wanting to string them all together and run them from one command button. I guess you call this a module for the entire workbook, but I am still struggling with the terminalogy of all this programming, so don't know for sure.
I added the code from the second sheet/command button to the end of the code from the first sheet/command button and joined them with a Call statement. Figured I would go about this sistematically, sheet by sheet. Instantly, I got an error message " Activate method of range class failed" when I ran it. At the start of the added code, I had added something like Worksheets("Sheet2").Activate figuring that I needed to activate that worksheet in order to make the rest of the code work. That is where I got the error.
Sorry for the long winded explanation. Can someone tell me what I need to add/do in order for the code to run without error as I string together all the pieces from each sheet?
View 6 Replies
View Related
May 16, 2014
i want to type 1-1 in my excel sheet and it is automatically coverting to 1-Jan and then i checked for formatting to the way i want then i founf excel automatically selecting custom option in format then if i select general my 1-jan is converting to 41640 number. Now i want excel sheet should show what typed in it i .e. 1-1 only.
View 2 Replies
View Related
Feb 18, 2014
I have a work sheet named "Main_List"...In column D starting with "D2" I would like to list worksheets that I would like to have printed via VBA.
The workbook has several hundred worksheets and I would like to list in column D only worksheets that I would like to print with VBA code.
View 3 Replies
View Related
Dec 26, 2009
I have a workbook with 26 sheets, labelled A to Z. Column A in all the sheets have names from rows A6:A35.
I need a macro or a code to extract all the names from each of the 26 sheets and paste it to a new sheet 'Names' under column A, such that names starting with 'B' paste under all the names 'A' and so forth till 'Z'.
View 9 Replies
View Related