public variables

  1. N

    Before printing excel worksheet, disable if it was done by file menu and enable if by button on a sheet

    I'm trying to resolve an issue with printing a sheet in Excel. So I was wondering whether there is a way to allow printing via button only. In ThisWorkbook I put the code below. What should I put in a module? How to pass 'button_used' variable from module back to ThisWorkbook? Public Sub...
  2. B

    Store Update Date in Public/Global Variable

    Hello. I have current code that will write a date to a worksheet after the code has successfully run. The code just updates sheet data from a report, which isn't relevant to this question. However, the reason the code writes the update date to the sheet is so that it can be used in a...
  3. E

    Public variable value not being shared by other modules

    Hi guys. I'm fairly new to VBA and I'm having a small problem here. On a certain project I'm working on I have declared a couple of public Boolean variables. The value of this variable is consistent inside the same module, but if for example I change the value of Public x as Boolean to True in...
  4. andrewb90

    Declaring Public values in userform

    Hello all, I haven't really used much in the way of public variables before, so I seem to be doing something wrong. In my userform, I have declared: Public closeResend As String at the very top. Now I have this: closeResend = "Yes" as one of the commandbutton click functions. In my module...
  5. S

    Question about variables & public variables

    Hello All, So I wanted to change the way I create macros usually (I'm no expert but want to be one), and decided that I want to declare my variables once as public if I use them in multiple modules and subs. And I had an example like this: Option Explicit 'Variables only here Public wsP...
  6. H

    Public variables losing their values

    My VBA application consists of many procedures stored in several modules in one workbook. I have 2 key public variables: a Workbook object that points to any one of several data books. a String variable holding the basic name of the current data book. They are declared at the top of a...
  7. C

    Is sharing variables between different VBA code executions reliable?

    Hallo, as I noticed, variables, which are declared as public, or on the module level are preserved after finishing VBA code execution, and they are kept in memory until workbook is closed, some error occurs etc.. I’m working on project, where it is necessary to keep some values of variables, and...
  8. V

    Public variable

    I have 4 variables that are used between the vba that is run on the worksheet and the userform that elicits responses from the user. The four are declared in the general module like this: Public KorS As String Public ActivityID As String Public varsaveme As String I am populating the...
  9. U

    How can I clear a public value when all applications end?

    I have a Worksheet_Change routine that works beautifully except for one Public variable. The program processes job schedules and when a job schedule goes into next year it duplicates the existing worksheet and when it updates that worksheet the Worksheet_Change kicks in and returns the weeks it...
  10. F

    VBA Userform Control("ComboBox" & i) issue and calling moduel

    Hello, Why won't "control()" work inside a moduel which is called uppon from a click action of a button?? Basically this code works fine: (inside a module and the userform button calls this macro) Sub test1() If UserForm1.CommandButton1.Caption = "Unlock" Then...
  11. Randall00

    Quick Question on Variable Scope - "Public" is misbehaving...

    I'm having a hard time understanding how Public variables declared in an Excel workbook retain their values. Every source I can find suggests that all variables declared as "Public" store values that are available to all procedures across all the workbook modules. These Public variables are...

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top