Excel Visual Basic Variables, Part 1: Variable Types
Subscribe to continue reading
Subscribe to get access to the rest of this post and other subscriber-only content.
Subscribe to get access to the rest of this post and other subscriber-only content.
In our previous post, we looked at connecting VBA code to command buttons on the Worksheet, the Quick Access Toolbar and the Ribbon. What about the other Form Controls: The Combo Box, List Box, or Check Box? How about Option Buttons, the Scroll Bar, the Spin button, the Label, etc.? That’s coming up in this…
1. What are Controls? First, some terminology. If you wanted to run a macro from a worksheet, you could create a button on the worksheet for the user to click. Such a button is a Control. There are many types of controls, which we will use in a later post. Apart from Command Buttons to…
The easiest way to create a macro is: The instructions below are for Excel. Word is similar, but has its own quirks (and no “Absolute or Relative”). If you want to look at programming basics first, see this previous post. 1. Recording a Macro Absolute or Relative What does that mean? When you record Absolute,…
In an earlier post, we recorded two Excel macros in Visual Basic, and ran them. Then, in the next post, we viewed the code in the Excel Visual Basic Editor. Code you have recorded will usually run. However, you may want to change it for all sorts of reasons. To tidy it up, make it…
The Manning formula for open-channel flow is: whereV= Velocityn = Manning’s “n”,r = Hydraulic radius = area / wetted perimeter = b*y / (2*y + b) for a rectangular channel (where y = depth and b = width), ands = slope of channel (m/m). Discharge Q = V*A = V*b*y. We cannot solve this…
1. The Application Keyword Use “Application” to refer to Excel, e.g.: Application.ActivePrinter Name of the Active Printer.Application.Name Name of the program running (“Microsoft Excel”).Application.Path The path from which the program is running. 2. ActiveControl Instead of the name of a specific control (e.g. txtEdit), you can use the keyword ActiveControl. This will let your program refer…