Executing Code In Different Sheets

Apr 2, 2008

I have a workbook with several worksheets. The numbers entered by the user in the cells C7:C9 of sheet "A" will be used to calculate some values in sheet "A" as well as in sheet "B".

Calculations on both sheets involve macros: macro "scale" on sheet "A" and macro "sort" on sheet "B".

I used this code to execute macro "scale" on sheet "A" triggered by the Worksheet_Change function:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("C7:C9")) Is Nothing Then
Exit Sub
Else
scale
End If
End Sub

now, I want to execute macro "sort" on sheet "B" practically at the same time (with the same worksheet_change condition for sheet "A")

All off my attempts resulted in running "sort" in sheet "A" which is not what I want. I couldn't get it to execute the macro in the other worksheet.
Already tried "With Worksheet("B") and "Dim ws As Worksheet, Set ws = Worksheets("B") - no luck...

View 9 Replies


ADVERTISEMENT

How To Avoid Displaying Movement Across Sheets While Executing VBA Code

Feb 5, 2014

I have written a vba code which does some calculation on the data on sheet 1 and then puts this data on sheet3 and after the calculation is done it puts the result on a few comboboxes on sheet2. Now the issue is while this whole calculation is performed by excel, I can see the movement in between the sheets. I want to avoid seeing this movement ?

Is it because of multiple Sheet.Select statements inside the vba code ?

View 3 Replies View Related

Executing Checkboxclick With Code

Mar 21, 2007

I have a series of checkboxes that I would like to select/deselect on mass, without having to manually click them individually...

Each of the CheckBox_Click routines change the visibility properties of images.

Changing the CheckBox value with code (true/false)

CheckBox.value = True

will alter the checkbox, but not execute its code...
And

Run "CheckBox_Click"

did not do it either.

How do I simulate the clicking of the CheckBox, with code?

View 3 Replies View Related

Auto Shutdown Code Not Executing

Nov 20, 2007

I have a workbook which autosaves and closes if no data is input for 10 minutes. It resides on a drive accessable by all our team and is set so that only one person can have read/ wrote access at a time. It tests for read only, shuts down if it is and saves and shuts down if not.

I have noticed that it doesn't work if the workbook is waiting for input.

I.e. someone starts to enter text, or something, in a cell, then goes off to make a coffee or whatever leaving the entry cursor sitting there blinking. It will not shut down after the ten minutes with no input.

View 9 Replies View Related

Automatic Break When Executing Code

Mar 29, 2005

I have finaly completed my project to include all the bells and whistle needed to make an ok task a bit more exciting. However, i am having a problem when the code is executing. It seems to "break" at random points in the process. I am not able to duplicate this error at my home (nor do i want to) and I can not quite figure out what is causing this as it only happens at my work computer. I have tried my coworkers computer and the code executes flawlessly like at my home.

Strangely enough, when the code breaks I am able to hit 'continue' and it continues on its way until the next hiccup. Please assist as this fluke is causing my brain to spiral.

View 9 Replies View Related

Vba Executing Text Strings As Code

Apr 5, 2007

if I can send text to a macro and have VBA treat the text as a line of code?

Suppose in a worksheet in cell A1 there is the following "text"
msgbox "hi there"

can you get vba to do the following:

Sub runtext()
Mytext = sheets(1).range("a1").text
XXXXXX Mytext
End Sub

where "XXXXXX" is a method or command that will cuase vba to evaluate the text string and run it as a line of code (returning a message box saying "hi there")

I don't want to send variables/objects to an existing method in VBA - I want to send the method to VBA....

View 5 Replies View Related

Finding Item In Array Then Executing Code?

Apr 25, 2014

I am trying to find an item within an array and then VBA could execute code.

Here is an example:

[Code]....

LookupItems =("text", "value", "book") or should I acutally be using Split("text,value,book",",")

For Each sht in ThisWorkbook
If sht.name = array(LookupItems) Then.....execute code

[Code] ....

So basically in this example I want to loop through all the sheet names in the workbook and if any of the names in the arrary are found it will execute the code for those particular sheet names.

I know alternatives are the select case or write an if statement for each value I am looking up or even use an OR for each value to lookup; but I just wanted to see if this method was even possible as it would be less coding.

View 2 Replies View Related

Check Users Permissions Before Executing Code

Apr 13, 2011

I have a file I created which works fine for me, on my machine at least but there are two issues I'm trying to sort out.

The first issue is I need to share the file with others who may not have the same access rights. I have something loading in the Workbook_Open event which I want to bypass for users who do not have access to a specific folder. So I was trying to check their access using Dir(path) = "" at the top level folder to see if any files are present (which there are). My assumption was that if it finds files it's safe to assume they have permission and it's ok to continue, otherwise they don't in which case I want abort the rest of the code. This seems to work fine for me but I tried testing with someone I know does not have access and it gave her a compile error.

Part of the code in macro utilizes FileSystemObject which seems to be the line where the code bombs on my coworkers machine. The FSO seems related to appears related to the Microsoft Scripting Runtime reference, but it's not enabled on my machine or any of the others. I vaguely remember having to do something on my machine awhile back for the life of me don't remember what it was.

The second issue is an MS Forms error: "Could not load some objects because they are not available on this machine." appears when opening the file on three of the machines I tested but it does not appear on my machine. I've tried looking at the references and could not find any differences between the machines. I pored through various postings online and it appears it might be worth re-registering the DLL/OCX files but we need admin rights to do that so I will need to open a request with our support team.

View 2 Replies View Related

VBA Code To Copy / Move 12 Sheets To Master Sheets

Jun 24, 2014

I need to do VBA coding. Got 12 Sheets for 12 month of Sales. Every Sheets are in same Header Format.

For Column R (Status), there's Filter Data "TRUE" and "FALSE". I have to move/copy "TRUE" item into Sheet Aging 2014.

I manage to transfer using only one Sheets using Advanced Filter VBA, failed with other Sheet.

I attached the file : Sales 2014.xlsx‎

View 5 Replies View Related

Executing Sub Within A Sub

Jul 17, 2008

I have a combobox which is used to select data (stock symbol) from a list. Following selection of the stock symbol, a VBA routine is invoked from a radio button which accesses the internet to get data for the selected stock. Currently, this is a two step operation. I tried to cut out the need to click on the download button by calling the GetData sub inside the combobox sub as shown in the code below.

View 14 Replies View Related

Not Executing Second Sub

Apr 30, 2013

Why the second sub is not executing?

Code:
Private Sub RolloverYear_Click()

Application.ScreenUpdating = False
Dim s As Variant
Dim resp As Long
resp = MsgBox(prompt:="You are about to clear ALL current year payroll information. Are you sure you want to continue?", Buttons:=vbYesNo)
If resp = vbNo Then

[Code] .......

View 9 Replies View Related

Executing Multiple SQL Statements At Once

Oct 4, 2008

if it is possible to use a batch query to execute more than one SQL statement at once from Excel. Something like this:

View 9 Replies View Related

Executing Two Different Commands With Same Button

Dec 17, 2008

I just want to have a column sorted by Z-A order and then A-Z by the same button, I recorded 2 macros on 2 buttons and tried to join codes with "if, elseif".

View 6 Replies View Related

Process Of Executing Macro

Aug 30, 2009

I wanted to know If there a way to hide the process of executing macrob (vba)?
I have a long macro that runs on a file and I want to hide the process. I know there is an option to it, I just don't know it.

View 5 Replies View Related

Executing The Same Subroutine For All Checkboxes

Mar 6, 2008

I have 60 checkboxes on my spreadsheet and basically, when any of the checkboxes are clicked on, the same action should be performed.

The only way I know how to do this is if I were to write the same code 60 times... one for each checkbox_click() method.

View 9 Replies View Related

Error Trap Always Executing

May 22, 2009

The error trap does work when there is an error, but it also runs at the end of the code when there isn't an error... I'm not sure what I've done wrong. When I test with data that is correct, it still runs through the code when it gets to the bottom. Have I put the error trap in the wrong place?

I have put in bold the section of the code with the error trap.


Option Explicit

Const TargetDB = "Group Life Pricing Tables v0.1.accdb"

Sub HMUK_Val()
Application.ScreenUpdating = False

'define variables to be used in the process
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sSQL As String
Dim SchemeInfo As Integer
Dim CurrentAge As Integer
Dim CurrentRow As Integer
Dim CurrentSex As String
Dim Message
'check that Scheme data has already been entered
For SchemeInfo = 1 To 13
If Sheets("Working Info").Cells(SchemeInfo, 2).Value = "" Then
Message = MsgBox("Please ensure all Scheme information has been entered before processing member info", vbOKOnly, "Warning")
Exit Sub
End If
Next SchemeInfo

View 9 Replies View Related

Add Spreadsheet While Executing Query

Dec 10, 2009

(Excel 2003)

I've a macro (I recorded) that executes a query (Oracle) and returns rows that exceeds the max (65539). How do I go about adding another sheet therefore allowing the query to continue?

I know how to do it via opening a text file and importing, but do not know how to do it with the use of a query.

View 9 Replies View Related

Worksheet_change Executing Selectively

Apr 4, 2007

I have a Worksheet_Change method in my sheet module which has suddenly begun working selectively. I have several target ranges in my worksheet that I need to watch for changes. One range of cells is all pull-down menus (a list of electrical loads through excel's validation), another two cells are looking at the name and location of an electrical panel.

When the user selects an electrical load, the worksheet_change method updates a legend of definitions. When the user enters a new name or location, the method updates similar fields elsewhere on the same sheet.

The problem is, excel has stopped executing worksheet_change when a load is chosen or location entered. It only executes when the aforementioned load and location are deleted. However, the name field triggers worksheet_change just fine!

I have attempted to put breakpoints on the worksheet_change method; Excel does not even execute the method as described above. I've tried breaking on the toggling of Application.EnableEvents (which occurs early on in the execution of worksheet_change). I currently have a global watch on Application.EnableEvents and I'm quite sure it's TRUE before I attempt to trigger a worksheet_change event.

My next step is to create a brand new workbook and copy my spreadsheet and code into it. I'll post the results of that experiment.

View 9 Replies View Related

Correct Syntax For Executing Vba

Apr 26, 2007

What I want to do is make a simple text link inside of a cell so when it's clicked on it executes the CommandButton(x) VBA script.

I'm guessing =HYPERLINK is going to be the best method.

Like so:

=HYPERLINK("Forms.CommandButton1","E-Mail")

View 9 Replies View Related

Executing A SHIFT+xlUP Syntax

Nov 14, 2009

What is the syntax for executing a 'SHIFT+xlUP' function in an Excel macro?

View 4 Replies View Related

Time Delay When Executing Macro In VBA

Mar 14, 2013

I am trying to see if it is possible to create an intentional delay when executing a macro. Basically I would like to pause the macro for 5 seconds and then continue with the rest of the code.

Is such a thing possible with Excel?

View 2 Replies View Related

Validate Userform Data Before Executing Sub Procedure

Jul 2, 2014

I have a Userform that has 4 Textboxes (named TextBox1, TextBox2, TextBox3 and Textbox4) and 7 Option Buttons (named OptionButton1, OptionButton2, OptionButton3, OptionButton4, OptionButton5, OptionButton6 and OptionButton7). I need to validate that the following criteria is met:

TextBox1.Value Does not = ""
TextBox2.Value Does not = ""
TextBox3.Value Does not = ""
TextBox4.Value Does not = ""

One Option Button is selected. (It can be any one of them 1-7, Just one needs to be selected).

Is there an easy way to check this data before executing a sub procedure to move the data?? Here is my try at it:

Code:
Sub CheckData()

'Is this the correct way to check data ?
If TextBox1.Value = "" Then
TextBox1.SetFocus
MsgBox "Please enter a Batch Date", vbCritical

[Code] .......

View 9 Replies View Related

Delete Macros In New Workbook OR Stop Them From Executing

Jul 7, 2014

I've got a macro embedded in a sheet (not in a module)..."Private Sub worksheet_activate()".

I have a macro that copies this specific sheet to a new workbook in order for other users to play with.

Problem is, when they select the new copied sheet in the new workbook, it tries to execute the "worksheet_activate" macro.

I've done searches on trying to delete macros but to no avail....

View 2 Replies View Related

When Executing The Macro, I Get Double The Page References

Aug 9, 2008

I am using Office 2007 and perhaps that is my issue. When executing the macro, I get double the page references than there actually are. My workbook has approx. 330 pages and when the macro finishes I have over 700. Certain tabs have a different page setup, and I assume that the macor only takes the regular pagination into consideration. I have landscape as well as portrait setup.

I also receive the errors upon completion in the bolded areas:

Sub CreateTableOfContents()
' Copyright 1999 MrExcel.com
' Determine if there is already a Table of Contents
TOCFound = False
For Each s In Worksheets
If s.Name = "Table of Contents" Then
TOCFound = True
Exit For
End If

View 9 Replies View Related

Executing A Program, Initialize Or Open An Application

May 18, 2007

When running a script within Excel, is there a way to cause the script to initialize or open an application other than Excel? For instance: If I desired to have the script open 'C:program.exe' is there script available for this?

View 3 Replies View Related

Executing Part Of Macro Only On Cells Meeting A Condition

Jul 11, 2009

I'm working on a spreadsheet designed to track total overtime hours worked in a year; on the spreadsheeet is a column to keep track of each day's total OT, the week's total OT, as well as a column to track the year's total. There is a formula in the week total, but the year total is calculated via a macro (day of the week total, added to the existing year total, result updated, so, each day has it's own button and macro). We have a shift that works a different week than the shift that needs to track overtime, but still must be included in the list.

Therefore, I created a column to place the shift designator so there can be recognizable diffrerentiation. With quite a bit of help from this board, and others, I've created (or been kindly given) the following macro (this is just a part of it) to total the day's overtime and existing year overtime and input the result into the cell. I now need to have this executed only when the condition I specify (say, in cell D1) is met (that would be the shift, for example the text M1 or SST). Please note, the week totals are only for user reference - they do not come into play for calculations of year totals. The below macro actually takes the totals from a day of the week and adds it to the existing year total, placing the result in the year total column.

View 2 Replies View Related

VBA -Determine Last Row Of Source Data Tab For Use In Executing Formulas In Template Tab

May 7, 2008

I am currently building a workbook with 2 tabs.

The first is a data dump tab. The number of rows used in this tab will change each time it is used.

The second tab currently has a header row and in cells A2-H2 are formulas based on data in the first tab.

I am creating a macro to autofill those formulas, but I don't know how to determine what is the last row of data in the 1st tab and use that as reference in my macro.

View 9 Replies View Related

Accidently Executing A Macro On The Wrong Sheet Within A Workbook

Sep 3, 2009

When running a macro is there a way you can execute code on another sheet within a workbook without being in the original sheet?

I seem to have a problem if I accidentally run a macro not on the original sheet whereby the code is executed and fills over data not in the desired sheet and the previous cells information is lost and the only way to fix the problem is to close the workbook and re-open a saved copy as you can't undo?

View 9 Replies View Related

Ribbon And Quick Access Buttons Not Executing Macros Assigned To Them

Jun 6, 2013

I noticed that my custom "Close without Saving" button stopped working. I checked the VBA editor and my Personal workbook was missing and all of my personal macros were gone. I restarted excel, same issue. Rebooted my machine and they re-appeared. Not sure how what happened, but at least the Personal workbook was not lost. I'm working off my company's network, so often I get the "Personal Workbook is locked for editing" message. I usually select the open as read-only file and go about my merry way. Perhaps I clicked something different on accident without paying attention.

Anyway, I digress, the custom macro button that I had in my ribbon still didn't work, so I removed it and tried again in both the ribbon and the quick access toolbar with no success. The Macro executes if I execute it manually or via the keyboard shortcut, but the ribbon/quick access toolbar buttons won't work. Frustrating, because I use this quite often. I've even tried writing a quick "dummy" macro to see if it was some sort of code error related to the macro, but got the same result. My "Close without saving" code is below (super basic code).

Sub Close_Without_Saving()'' Close_Without_Saving Macro' Closes active workbook without saving changes.'' Keyboard Shortcut: Ctrl+q' ActiveWorkbook.Close (False)End Sub

View 1 Replies View Related

VB Code To Add And Delete Row From Sheets

Mar 27, 2014

I would like to add 2 buttons to each page. One button to add a row at the bottom of the table while keeping all of the same formatting and another button to Delete a selected row from the table. So that if there is more assignments than allowed in the current table, a row could easily be added.

I would think that the code for the class sheets would all be the same.

The other obstacle I thought about is possible making a button on the Summary page that would add another sheet, call it Class and whatever number comes next and also add it to the summary table with the same formatting (including the hyperlink that's in the Classes column where it will take you to the Class sheet that you want to drill down to).

I have attached the file. If the summary sheet is took much work it's not a big deal, I would be fine with just being able to have 2 buttons on the class sheets that allowed them to add and remove and such.

I would also like to contribute. I know a decent amount about SQL and SSRS/SSIS Reporting services.

I also need it to be able to unprotect my worksheet and then protect it back, Since I will only want them to be able to type in the areas I specify. I also moved the summary at the bottom of each class sheet to the right side at the top so its easier for them to view.

View 5 Replies View Related







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