Macro To Run On Sheets Without Selection

Feb 10, 2007

Is there any way this code (below) can be modified so that the macro runs without actually selecting the sheet it requires. The reason for this is so i can hide the sheet (Column Output 3) from view so the data isnt displayed. at the moment the sheet is on view and i would rather it werent. this is the code i have

Sub DistributeRows()
Sheet11.Select
Cells.Select
Application.CutCopyMode = False
Selection.ClearContents
Dim wsAll As Worksheet
Dim wsCrit As Worksheet
Dim wsNew As Worksheet
Dim rngCrit As Range
Dim LastRow As Long
Set wsAll = Worksheets("Column Output 2")
LastRow = wsAll.Range("A" & Rows.Count).End(xlUp).Row
Set wsCrit = Worksheets.Add
Set wsNew = Worksheets("Column Output 3")..............

View 5 Replies


ADVERTISEMENT

Macro To Unhide / Hide Sheets With Combobox Selection

Jun 18, 2007

I have a workbook that contains approx 50 sheets and will grow to somewhere in the region of 200.

The majority of sheets, which contain the raw data referenced by the renaining sheets, are hidden. I will occasionally need to update the data in some of those hidden sheets and would like an easy / quick way of unhiding them.

The front page has several comboboxes which select the page needed for the calculation being performed, eg I select Chapter2 in the first combobox, section 4 in the second and page 12 in the 3rd. The output is combined / abbreviated into into a cell eg Ch2-Sec4-P12. That being the name of a sheet I then use INDIRECTs to retrieve the data I want and place it in a spare sheet, that works well.

I'd like to do the same to select the sheet to unhide. I can setup the comboboxes to give the name of the sheet I want to unhide / hide in a cell but then I'm stuck;

How can I use the contents of a cell in place of the sheet name in a macro command such as Sheets("data").Visible = Not (Sheets("data").Visible) ?

View 9 Replies View Related

Unhiding Sheets With Combobox Selection And Duplicating Sheets Automatically

Sep 27, 2011

I have 25 sheets in the workbook and a combobox on the main page, The combobox references a range of 1-25 that represents the 25 hidden pages. right now i can get the sheets to unhide one at a time based on the selection e.g. combobox option 1 will unhide sheet 1 but the sheet are representing sites in a design so i need to have the option to select multiple sites in the combobox option so for example if i select 5 then sheets 1-5 should unhide. I hope I've explained that clearly.

The other question or option would be to just duplicate sheet 1 based on the combobox selection e.g. selection 5 duplicates sheet 1 5 times.

View 9 Replies View Related

Hiding Of Sheets Through Yes Or No Selection?

Aug 19, 2013

I wanted to know if there is any function/macro/option available which can hide/show sheets based on the value selected in the particular cell.

Basically i will have a table of contents as the first sheet. Post that if 'Yes' is selected against a particular line item, the sheet for the same should appear. If 'no' is selected the sheet would remain hidden. The sheets would be linked via hyperlink to the particulars (name) for each line of the table of contents. If required i can also remove the hyperlinking of cell.

View 6 Replies View Related

Automatic Selection Of Parts Of Lists To Other Sheets

Mar 25, 2013

I was wondering if there is an easy function that would copy only some part of a list as if like I select a category.

Let me elaborate. As in a previous post i have a list of apartments and a set of categories (locations, tube stations, number rooms, distance to tube stations, etc).

I want to get all the items that are the same from a category and post them automaticly on another sheet to single them out, for instance all of them that are on Liverpool Street station or all of them that have 2 rooms.

Is there a simple way to do this or do I have to get a macro to read my whole list? I ask cause I am continuasly updating the list and don't want to recreate the formula all the time.

View 6 Replies View Related

Populating Two Listboxes With Sheets Based On Cell Value; Printing Their Selection

Jul 29, 2009

I would like to do is have 2 listboxes. In the first listbox I would like the name of all the worksheets which contain the words "elective class: " in cell C7.

In the second listbox I would like the name of all the worksheets which do not contain the words "elective class: " in C7. I need this only to source from worksheet 7 onwards however.

The listboxes are called ListBox1 and ListBox2 respectively.

Also I am using this to print and I have a button which currently selects all the data in the first listbox and another button which prints all the selected data. The code being used for this is:

View 2 Replies View Related

Macro For Selection Of Files

Apr 14, 2014

How to create a macro that selects only the 2nd file in a folder to be opened instead of every file.

So far the code below is opening every file.

Sub ConsolidateAll()

Dim wkbConsol As Workbook
Dim wksConsol As Worksheet
Dim wkbOpen As Workbook
Dim wksOpen As Worksheet
Dim FolderName As String
Dim FileName As String
Dim Cnt As Long

Application.ScreenUpdating = False

[Code] .......

View 2 Replies View Related

Macro To Print Selection

Nov 20, 2008

I seem to be getting myself into a complete muddle as was wondering if someone to help me with a Printing problem.

On the attached sample, i'm trying to write a macro to print the selection but only print where the status is "Active" to the ned of the selection. However, the spreadsheet is changing on a daily basis i.e. new lines being added and lines being taken off.

So, to take potential of user error out i wanted a macro to print the "active" selection.

View 9 Replies View Related

Macro For Selection Delete

Dec 31, 2008

This is a piece of code from a macro that i am altering. I keep getting an error when i get to the 2nd line.

View 7 Replies View Related

Selection.End(xlToRight) In A Macro

Jun 18, 2009

I have data in cells C3 through E3, then a blank column, followed by data in cells G3 through I3. When I use excel to record a macro, it produces the following.

Range("C3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select

However, when I run the macro, it only selects cells C3 through E3. How do I get it to continue through the blank column? I tried to make this example as simple as possible.

View 9 Replies View Related

Macro For Cut / Paste Selection Of Cells?

Jun 6, 2014

I need a macro that can cut and paste a selection of 3 cells to a location one row above and 3 cells to the left. I want to run it each time manually from the right cell among the 3. the macro should therefore (when standing on the right cell of the 3):

1. select 2 more cells to the left
2. cut the selection
3. move 3 cells to the left and one cell up
4. paste
5. move the cursor back to the starting location

see attached pic for example.macro needed.JPG

View 2 Replies View Related

Default Dropdown Selection Using Macro

Dec 21, 2009

I have an excel file with a date dropdown box. The date is populated from another sheet in the same file. I need to create a macro, which will select the latest date by default when the file is opened. Is this possible and if so could someone please lead me in the right direction? I am using Excel 2003 and the date format in the dropdown box is "dd-Mon-yy" --> eg "21-Dec-09"

View 9 Replies View Related

Macro To Print Selection On Worksheet?

Mar 18, 2013

I tried recording a macro but I am keep on getting an error. I need a macro which will print the selection of A1:D28 on a worksheet called Invoice. The print needs to be scaled at 165% of its normal size. i need it to be normal margins and if possible any printer.

View 1 Replies View Related

Smart Range Selection In Macro

May 22, 2013

Im having some problems with range selection in macros. Basically, what the macro does is Copy / Paste as Values in differet sectors of an active worksheet, so this is the code for each range of cells that I need to copy paste:

Code:

ActiveSheet.Range("C14:E15").Select
Selection.Copy
ActiveSheet.Range("C14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

The problem with this code, is that because it specifies EXACTLY which range to select, if I add a row before that range the macro will be now selecting an incorrect range.

For example, say I have a value on cell A5, and the macro is set up to copy/paste that cell. Later on, I decide to add a row in A3, so the value I would need to copy/paste will now be in A6, but the macro will still execute on A5 (incorrect, as it should now execute in A6, and that is what I have to manually correct each time).

View 3 Replies View Related

Auto Selection Of Cell In Macro

Jan 31, 2007

i am using user form to run some macro and i like that after running macro the cursor will return to the active cell , at the moment the cursor located on the user form.

View 9 Replies View Related

Selection.Copy And Find Macro

Mar 7, 2007

I have is two spreadsheets with different data on them, but the only connector is the user ID, so I want the cell I select with the user ID to be copied it then switches to the other spreadsheet and finds the copied selection, it then takes the columns on the selection of A to J and pastes them back in the other columns in the other spreadsheet.

My only real problem is that I can't get it to use the selection.copy in the find to select the cells I need, any help would be great, thanks.

Code ( i put spaces bewteen the other parts and find function so you could easily see it):

Sub Macro1()

Selection.Copy
Windows("EMERA-employees-asof-06-Mar-2007.xls").Activate

Cells.Find(What:="(I want this to be selection.copy)", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

ActiveCell.Columns("A:J").Select
Application.CutCopyMode = False
Selection.Copy
Windows("SMSReportResults.xls").Activate
ActiveCell.Offset(0, 6).Range("A1").Select
ActiveSheet.Paste
End Sub

View 9 Replies View Related

Run Macro On Selection Of Validated Cell

Mar 27, 2007

I have a macro that I am running "onentry" of a worksheet. The problem is that I have some cells that are validated to allow a list. If I manually type a word from the list in the validated cell the macro runs. However, if I make a selection from the list the macro does not run. I guess vba does not see my selection as an entry.

View 9 Replies View Related

Using A Macro/VBA To Automate Filter Selection

Oct 4, 2007

I've recorded a macro which selects "1" in a filter drop-down box then prints some pages, then comes back and selects "2" in the filter then prints some pages, etc etc etc.

I've looked at the code for this and it treats the "1", and the "2" etc as text each time - originally I had the filter on names, but the names change each time I need to do this whilst the process doesn't, so I filtered on numbers instead.

However, I would have to enter the repeated blocks of code down to 1000 to get it to select down to "1000" in the filter. About 3/4 lines each time but with me manually typing in 1, 2, 3, 4 .... 999, 1000.

Is there a way to say in VBA 'repeat filter selection until you've run out of numbers then come back to "All" and stop ?

View 9 Replies View Related

Controlling A Selection.Insert Macro

Dec 30, 2007

I have a simple macro that allows for inserting cells above the selected cell. It actually inserts 2 cells: above the selected one and above the one immediately to the right on the same row.

I need to add 2 features to prevent mess ups:

- The Active cell should only be on column "N" and after row 15 on the sheet. Any other cell selection should be ignored or ideally pop a warning to prompt user to select a > N15 cell.

- An OK/Cancel dialog box that pops up before execution and reads:
"Are you sure you want to skip "text_of_selected_cell" for date "text_of_Column-13_cell_on_same_row"?"

Sub SkipDayRelative()

ActiveCell.Offset(0, 0).Range("A1:B1").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End Sub

View 9 Replies View Related

ComboBox For Selection Sheet And Run Macro

Feb 5, 2008

I have got 8 sheets in a workbook having the following names first one is Main,and others are Aw,Nzm,Mhk,Gul,Qta,and Hdr.

I want a ComboBox in every sheet displaying names of all sheets in combobox and when i select a name of sheet from combobox it goes to that sheet after hidding sheet where selection was made and running macro codes which i have developed for sheet. I want only one sheet display on the screen when one selection is made other one is invisible.

View 9 Replies View Related

Extend Non-contiguous Row Selection In Macro

Sep 16, 2008

I get 40~100 page PDFs of purchase orders every week. Each page has one part number and its open order and forecast information. Some pages have a few line of information, some have many lines.

I convert this file into a txt file.

I then create a macro to import it as space delimited and format it.

What I need to do it get rid of the header/footer information on EVERY page.

When the txt file is created it doesn't have any page marks.

The header has "ABC Widgets" as the customer name and then 10 rows of unnecessary information. If I do a Find ALL for "ABC Widgets" and select all, it will delete that header line at every instance, but the leftover selected cells then start not-lining up (meaning I can't just hit "delete row" 10 times and have it pick the right row--the rows don't line up any more and each instance is -1 row offset.)

Is there any way to extend the selection of non-contiguous rows (starting with ABC Widgets) down by 10 so I can delete them?

View 9 Replies View Related

Macro To Run On A Dynamic Selection Range

Oct 13, 2008

I am looking to run a marco for a selection range, and the selection range could vary in size.
Using the Macro recorded (whilst turning on the relative reference) the Macro runs for a defined number of cells. I would like to run certain Macro, for different ranges of cells.

View 9 Replies View Related

Trigger Macro With Worksheet Tab Selection

Jan 14, 2004

I have a macro I'd like to run when a worksheet tab is selected. The macro updates content in various cells.

That action is now triggered with a command button (linked to macro), but I'd like it to take place when the user selects that worksheet tab.

View 9 Replies View Related

Allow User To Color Selection From VBA Macro

Sep 10, 2009

I see where I can use the following to bring up the color pallet

VB: AutoLinked keywords will cause extra spaces before keywords. Extra spacing is NOT transferred
when copy/pasting, but IS if the keyword uses "quotes".

Sub MyColors()
' brings up the colors dialog
Application.Dialogs.Item(xlDialogColorPalette).Show
End Sub

But I don't know where to go from here. I would simply like to have cells selected, run the macro, select a color from the dialog, press the ok button, and have the selected cells colored per the color selected in the dialog. (Of course, pressing cancel would exit without changing any colors.)

View 9 Replies View Related

Record Macro Relative To Selection

Jan 27, 2010

This recorded macro inserts a line below the cell that active when it was first recorded. It then copies some text and a formula to the line that was created.

Sub Macro11()
Rows("10:10").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A9:E9").Select
Selection.Copy
Range("A10").Select
ActiveSheet.Paste
Range("H9").Select
Application.CutCopyMode = False
Selection.Copy
Range("H10").Select
ActiveSheet.Paste
Range("F9").Select
End Sub

If you run this macro again at a different cell position, it goes back to the first starting position and repeats the same action. I see that the cell references from the first recording are fixed in the macro. I can't figure out how to make the macro use the new current cell position as the starting positiion when it runs again.

View 4 Replies View Related

Run Macro Based On ComboBox Selection

Jun 8, 2006

can i use a combo box with a dropbuttonclick to run the macro only when the arrow is selected . The problem I am having is the macro will run on the selection of the arrow which is whatt I want but it also run when I make a selection it the combo box

View 9 Replies View Related

Macro: Show Selection Values

Dec 14, 2006

I have selected 6 rows and 2 columns in a sheet and I have a button in the same sheet.Now I click the button it triggers the button_click where I have put msgbox to popup.But I need this selected value in message box instead of the my hard coded string.

sample value in the selected cell:

1,1.005
2, 3.006
.........
..........

View 3 Replies View Related

Macro: Sort Data Around Selection

Dec 22, 2006

how to sort a selected range.

The end of the range could be any cell. The top of the range is fixed in A1.

I've tried with this:

Sub Order()
Dim final As Variant
final = Selection.End(xlUp).Address
Range("A2").Select
Range("A1:" & final).Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range _
("G2"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
End Sub

View 9 Replies View Related

Run A Macro When Pivot Table Selection Changes

May 1, 2007

I have a macro that I would like to run once I change a selection in my pivot t able. is this possible?

View 4 Replies View Related

Macro To Stop If No Selection Made

Jun 14, 2007

If nothing is typed in and the OK button is pressed, it changes the entire sheet to values. I'd like the macro to stop if nothing is selected.

Dim sCol As String
sCol = InputBox("Select Column")
Set UserRange = Range(sCol & "9:" & sCol & "35")
UserRange.Value = UserRange.Value

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved