|
Introduction FAQ's
- Home page
What is 'spBasic'?
What spreadsheets
can use spBasic?
What's the
purpose of spBasic?
What is a 'program',
and why would I want to write one?
How do I use spBasic?
Why would I
want to use spBasic, can't I just use cell Formula's?
For the more complicated
programs, can't I use VBA?
Show me something
more complex than the 'SimpleProgram'
Does the
program have to be visible on the worksheet?
How
can I use spBasic to control Instrumentation?
Can I modify
spBasic to control my unique Hardware Equipment or my unique Systems?
I'm interested, what's
the next step?
How To
How
to Install spBasic
How to Create an spBasic
Program
How to Create an spBasic
Variable Column - Local and Global variables
How to Run an spBasic Program
How to Make a Run Button
How to Debug an
spBasic Program
How to Call SubPrograms
How to Call SubPrograms
- Pass by Address
How to Format
Cell Addresses using Workbook and Worksheet Names
Advanced
How to Use VBA
with spBasic
How
to Make an spBasic Add-In
For other Advanced topics, see
the Developer's Page
FAQ's - Using spBasic
General
Can
I use workbook and worksheet names with blanks in them?
How
do I address worksheet cells in other worksheets and workbooks?
How
do I hide spBasic program and variable columns?
I
accidentally moved an Excel message box underneath the spBasic Help window,
then Excel didn't respond to mouse clicks
I'm
debugging an spBasic program using the Debug form, but it seems to take
a long time between steps
How
can I display the line number of the spBasic program statement as it's
executing?
What
Fuctions are available in spBasic?
How
do I write logical functions in spBasic?
How
is the 'Indirect' Excel function used?
SpBasic Menus
The
spBasic Menus do not appear on the Excel menu bar or the right-click menu.
Variables,
Statements, and Cells
I
put a variable named 'x12' in my variable column, but I get a message
saying it's not valid.
I get Variable
Not Valid message if I use 'r' or 'c' as a variable. How come?
I get a "Variable Name is Not Valid" error for a variable in one worksheet, but it works on a different worksheet.
The
statement e2:e10 = 5 * d2:d10 + g2:g10 gives me an error. I want the formula
to apply for each cell. How to I do this?
Excel Text Editing,
Column and Cell Formatting
When
I type something into a cell, I get text inserted automatically. How do
I turn this off?
The
first letter in a cell capitalizes when I enter a variable name. How do I
turn this off?
I
entered a Date into a cell and Excel reformatted it. Now how do I format
the cell back to a number?
How do
I wrap the text in a cell?
Can
I use another text editor to write or modify an spBasic program?
I
use a single quote in front of a workbook name as a variable value, but
I get an error
What's
the story on the single quote character in Excel?
When
do I use double quotes in spBasic?
Some
of my Excel expressions do not work when I use spBasic variables
Error Messages
I get the message "Programmatic Access to Visual Basic Project is not trusted" when I try to use the spBasic Menu


I get a message "The following features cannot be saved in Macro Free workbooks" when I exit Excel 2007

I
get a "Error in loading Dll" message when I install the SpBasicAddIn.xla.
What does this mean?
I
keep getting 'Invalid Statement' errors in some Example program statements
I'm using
I
get a "Macro Disabled" message. What's wrong?
When I click on an spBasic Form, I just get a 'Beep'and nothing happens
I get a "Excel not responding" or "Component Busy" error.
What does this mean?
SpBasic Forms and Windows
How
do I add a statement to the last line of Help 'Favorites' Group?
Charts
How
do I find the chart name for a Chart embedded in a worksheet?
Can
I copy a chart into a worksheet?
I get
a "Chart Formula" error when I try to display certain charts
I've
created a "Strip Chart" using the 'Create Chart' menu. When
I select the "Run" option on the chart, only the last part of
the data points are displayed, not the beginning data points
I
can't access a Chart series collection from VBA
The data on the "Strip Chart" disappears when the chart data worksheet is changed
VBA and spBasic
How
can I run a VBA Macro or VBA Subroutine from spBasic?
I
have a Msgbox statement in a VBA macro I'm calling from spBasic. While
debugging the program the message box was displayed behind the Debug Form
and I couldn't get at it. I had to use Ctrl-Alt-Del to stop Excel and
start over
I'm
using a VBA function that I wrote, but it executes each time I add or
delete a cell on the worksheet. What's going on?
I
wrote a VBA function to use in an spBasic program. I put a break statement
in the function to debug it, but when I trace through the function I get
an spBasic error at the end
For other VBA topics, see the
Developer's Page
Protected
Worksheets
I've
protected a program worksheet with a Password, but now I can't run any
programs
I've
protected a program worksheet, and I'm running the program from another
worksheet, but now the second worksheet flashes when I run the program
Add-Ins
I
deleted an addin and added another addin with the same name, but when
I open Excel, the old addin is still there
Instrument
Control
When I put my computer in Standby to save power, and Excel is open, I loose my instrument connection
I
get a timeout error while running a RS-232 serial interface on my Dmm
after I send a SCPI command string. Any suggestions?
I
get a "Compile Error in Hidden Module" when I try to run any
Agilent 34401 or Dmm statement in my program
I
get a error when I try to use a resource string such as "GPIB0::8::INSTR"
or "ASRL1::INSTR" in a statement in my program.
How To
How to Install spBasic
See Downloads - Installation
for instructions on how to download and install spBasic.
How to Create an spBasic Program
See Getting Started with spBasic for a simple "HelloWorld" program
.
How to Create an spBasic Variable Column - Local and Global variables
Local Variables - These are variables which are local
to the program sheet. This means you can have the same variable names
on different program sheets without any conflict. The spBasic programs
on that sheet will automatically recognize the variables. The first row
of a variable column contains "// variables". The variable column
has a "End" anywhere after the last variable. You can create
a variable column by hand, or a simpler method is to select a cell in
the column where you want the variables, then select the spBasic Edit Form menu
item "Tools -> Create Variable Column". If you put
a comment mark "//" before any variable in the column, the variable
will be ignored. Click here
for more info on variables and variable columns.

Global Variables - These are variables which are global
to the workbook. Global variables are recognized by all spBasic programs
on all sheets in the workbook. The first row of a variable column contains
"// globals". The global variable column has a "End"
anywhere after the last global variable. You can create a global variable
column by hand, or a simpler method is to select a cell in the column
where you want the variables, then select the spBasic Edit Form menu item "Tools -> Create Global Column". If you put a comment mark
"//" before any variable in the column, the variable will be
ignored. Click here for more
info on variables and variable columns.

How to Run an spBasic Program
There are two basic ways to run a program
- Use the spBasic Edit Form
- Make a program Run button (this is usually a more convenient way
to run a program)
To run the progam using the spBasic Edit Form, just click on the R button (last button on the right) of the Edit form. You can also use the "Run/Debug -> Run Program" menu selection.
To make a Run button, click on a cell on the worksheet where you want the button to be located, then select the "Tools ->Create Buttons -> Create Run Button" menu item. Note that you can also create a Stop Button, or Both Buttons using the Create Buttons
selection.


Press OK, then right-click on the button and it will be selected as shown.
Left-click on the border and you can move the button or resize it. You
can also edit the text by clicking on it. Click anywhere on the worksheet
to exit the edit mode. Pressing the button will now run the program.
How to Debug an spBasic Program
See the Debug Display page.
How to Call SubPrograms
A subProgram is just a normal spBasic program which is called,
or run, by other spBasic programs. Here's a screen shot of program 'testProg'
calling a second program 'testSub'.

The program 'testSub' uses two variables, subIn and subOut. Subprograms
use spreadsheet cells to pass input variables and store output variables.
This subProgram simply multiplies the input variable by 10, adds 1, and
sets the output variable to the result.
The calling program 'testProg' can set the input variable in two ways.
You can set the input variable on a separate line, call the subprogram
by just using the name of the subprogram in the cell, and then use the
output (in this case cell d5 was set to the output value). This is shown
by lines 2, 3, and 4 of 'testProg' in the image above. The other way is to
set the variable 'subIn' on the same line as the subprogram call (this
is shown in line 5 above). The subprogram can be on another worksheet
or workbook as shown below,

Here 'testSub' and the variables are on sheet2 of the workbook. The variables are used with
the prefix 'sheet2!' to show they're located on Sheet2. 'testSub' does
not have to have a 'sheet2' prefix unless there's another program in the
workbook with the same name. The subprogram and variables can also be
in another workbook using the form '[<book name>]<sheet name>!<subProgram
or variable name>', e.g., '[book2]Sheet3!subIn' . The workbook has
to be open for this to work.
Call SubPrograms - Pass by Address
The examples above pass the arguments to the subprograms by setting the
value of the argument in the calling program (e.g., 'sheet2!subIn = 8',
'testSub subIn = 65'). This is fine for simple values. For a large range
of cells, however, you want to pass the Address of the cells rather than
copying all the cell values to the subprogram. The Addr() and the Replace
functions do this as shown in the following programs.


The first program 'testRef', calls the subprogram 'passByAddrTest'. The
'passByAddrTest' subprogram sums the values of a cell range using the
Excel SUM function. The cell range is defined by the value of the 'cellAddr'
variable. The Replace function '<< >>' replaces the variable
with it's value, so the term 'sumOut = SUM(<<cellAddr>>)'
becomes 'sumOut = SUM('[SpBasicPrograms.xls]FAQ Page'!d1:d10)'. The sumOut value
is then set to the sum of cells d1 to d10 of sheet1 in the book 'SpBasicPrograms.xls'.
The calling program 'testRef' sets the 'cellAddr' variable to the address
of cell range d1:d10 by using the Addr() function. This function computes
the full address (book and sheet) of the argument and returns the full
address string '[SpBasicPrograms.xls]FAQ Page'!d1:d10 (the single quotes before
the book name and after the sheet name are needed in case there are spaces
in the names). So, instead of copying cells d1:d10 to a subprogram buffer
area where the sum is computed, the program just passes the address of
the cell range using the Addr() function.
How to Format Cell Addresses using Workbook and Worksheet Names
The generic form for including workbook and worksheet names in cell addresses
is,
'[<workbook name (including '.xls' extension>]<worksheet name>'!<cell
address>
Examples:
[Book1.xls]Sheet2!d1:d20
'[Data Book.xls]Data Sheet'!d1:d20
[Book1.xls]Sheet2!Var1
'[Data Book.xls]Data Sheet'!Var1
where Var1 is a variable name. The single quotes are required
if the workbook or worksheet name contains any blanks. Be careful when
using cell addresses with a single quote ('[My Workbook.xls]My Sheet'!<cell
addr>) in a variable value column when the workbook or worksheet
contain blanks. The single quote will be dropped if it is the first char
in the cell. Put two single quotes before the workbook or worksheet in a variable value column when the workbook or worksheet contain blanks.
Default conditions,
- If no workbook or worksheet is specified, e.g. d1:d20,
the program workbook and worksheet is used.
- If a variable name is used and no workbook or worksheet is
specified, e.g.Var1, the variable in a worksheet '// variables' column
is used, OR a global name in the workbook defined by a '// globals' column
is used (a global workbook name can be defined in any sheet in the workbook).
All other names return an error. Click here
for more info on variables and variable columns.
- If the worksheet is specified but no workbook is used,
e.g. sheet1!d1:d20, 'Data Sheet'!Var1; the program workbook is used.
- If both the workbook and worksheet names are specified,
e.g. [book1.xls]sheet1!d1:d2, '[Data Book.xls]Data Sheet'!Var1; all all
addresses should be valid if the cell range or the variable name. Remember
- book names must include an '.xls' extension!
Advanced
How to Use VBA with spBasic
See Developer's Page - How
to Use VBA with spBasic
How to make an spBasic Add-In (.xla) file
See Custom Code - How to make an spBasic Add-In
For other Advanced HowTo's and Tips, see the
Developer's Page.
FAQ's (Freqently Asked Questions)
General
Can I use workbook and worksheet names with blanks
in them?
Yes, but you must use single quotes on the cell addresses on the
term before the !, such as,
'[My Workbook.xls]My Sheet'!e1
'My Sheet'!e1
'My Workbook.xls'!e1
Be careful when using cell addresses with blanks in a variable value
cells (the cells to the right of the variable names).
If you use the book or sheet name in a variable value cell, put two single quotes before the book or sheet name. If you just use one single quote, it will be dropped and the statement
will fail. The single quote in the first char of a cell tells excel that
you want to interpret the rest of the cell as a text string and it is
dropped. If you use two single quotes, the first on will be dropped but the second one will be valid. See What's the story
with the single quote character in Excel? below.
How do I address worksheet cells in
other worksheets and workbooks?
See How to Format Cell Addresses using
Workbook and Worksheet Names
How do I hide spBasic
variable columns?
You can hide Excel columns by selecting the columns and using the 'Format->Column->Hide'
menu selection.

To unhide the columns, put the cursor on the top column label row (A,B,C,
etc) slightly to the right of the border between the columns where the columns were hidden.
The cursor will turn into two double lines. Then right-click and select
'Unhide'.

The spBasic program will still run when the variable columns are hidden. The car
mileage example shows an example of hidden colums.
You can also hide entire sheets that may contain spBasic variable columns. To do this select the worksheet and using the 'Format->Sheet->Hide'
menu selection. To unhide the sheet, select 'Format->Sheet->Unhide'.
You can also password protect the sheet from being changed by using 'Tools
-> Protection -> Protect Sheet'. If protect the spBasic program
sheet, you have to use the spBasic 'SetPassword' statement as the first
statement of the program as explained under Protected
Worksheets. Also, remember to unlock all cells that you are changing
on non-program protected worksheets.
I had the spBasic Help window displayed, and
I accidentally moved an Excel message box underneath the Help window,
then Excel didn't respond to mouse clicks.
When using an spBasic Help or Edit window, keep it off to the side so
any Excel message boxes (such as insert cell messages, etc. ) are not
underneath the spBasic windows. This doesn't normally happen, but if it
does, you won't be able to get at the message box and you'll have to terminate
the Excel Application using cntrl-alt-delete.
I 'm debugging an spBasic program using the
Debug form, but it seems to take a long time between steps
Make sure there's an 'End' statement at the end of the program. The debug
mode will take longer to run when stepping through the program if there's
no 'End' statement.
How can I display the line number of the spBasic
program statement as it's executing?
The 'DisplayLineNumber' statement will display the program line number
being executed. The spBasic statement 'DisplayLineNumber d1' will display
the line number in cell D1.
What Fuctions are available in spBasic?
Any function that can be used in an Excel formula can be used in an spBasic
statement. SpBasic also has built-in functions, and you can write any
custom function using VBA.
How do I write logical functions in spBasic?
SpBasic Logical functions are in the Excel format -> AND(logical1,
logical2, etc), OR(logical1, logical2, etc). You can create complex functions
using combinations of AND and OR. For example, AND(logical1, OR(logical1,
logical2, etc), etc) = logical 1 AND (logical1 OR logical2).
Spbasic also provides the bit-for-bit logical functions BitAnd(arg1, arg2),
BitOr(arg1, arg2), and BitXor(arg1, arg2) that can be used for bit testing
and bit masking. SpBasic statements can contain any valid Excel function.
Any function that can be used in an Excel formula can be used in an spBasic
statement.
How is the 'Indirect' Excel function used?
This function will turn a string into a reference. For example, if a cell
G1 contains the text value 'A30', then the function 'Sum(indirect("A1:"
& g1))' will sum the cells from A1:A30. SpBasic has an Replacement
function (written as '<<address>>') which can be used in this
situation. The example Sum term would be written as 'Sum(A1:<<g1>>)'.
The replacement function replaces the address term with it's value, so
the resulting statement would be 'Sum(A1:A30)'.
SpBasic Menus
The spBasic Menus do not appear on the Excel menu
bar or the right-click menu.
Go to the Excel AddIn menu (Tools->AddIns) and uncheck the
spBasic AddIn 'SPB AddIn', and press OK. Now, go to the Excel AddIn menu
again (Tools->AddIns), and this time recheck the spBasic AddIn
'SPB AddIn' (the box beside the AddIn should be checked). Then press OK.
The spBasic menus should appear.
In Excel 2000, the spBasic menu may not appear if the Excel.xlb
toolbar file was deleted or corrupted. If the toolbar file is corrupted,
you may get a "The System Is Dangerously Low on Resources" message.
Search for the Excel.xlb on your system and delete it if it exists.
Then open a workbook and Uncheck and Check the spBasic AddIn as described
above.
Variables, Statements, and Cells
I put a variable named 'x12' in my variable column,
but I get a message saying it's not valid.
Variable names can be single or multiple characters (e.g. i, x, aVar5,
minVolts, etc), but can't be 1 or 2 characters followed by a number (e.g.
x1, c6, aa5, bc678, etc.) which are reserved for cell addresses.
I get Variable Not Valid message if I use 'r'
or 'c' as a variable. How come?
These are reserved for Excel use ('row' and 'column') and can't be used
for spBasic variables.
I get a "Variable Name is Not Valid" error for a variable in one worksheet, but it works on a different worksheet.
The worksheet name with the problem has a apostrophe in it (e.g., "Joe's worksheet") or some other character that's causing a problem . Change the name of the worksheet and try again.
The statement e2:e10 = 5 * d2:d10 + g2:g10
gives me an error. I want the formula to apply for each cell. How to I
do this?
Use the Range() function on the right side of the equation.
e2:e10 = 5 * Range(d2:d10) + Range(g2:g10)
You could also use a loop statement to loop over the cell addresses,
but the Range function is quicker and more convienient
Excel Text Editing, Column and Cell Formatting
When I type something into a cell, I get text
inserted automatically. How do I turn this off?
Set the Excel Edit options, use the menu item Tools -> Options
-> Edit tab. Set "AutoComplete for cell values" off. If you
have any other editing problems, look at these options to see if Excel
is doing things automatically that you don't want.
The first letter in a cell capitalizes when
I enter a variable name. How do I turn this off?
Turn the Autocorrect options off. This is in the Excel menu under 'Tools->Autocorrect'.
Uncheck all the options and press OK.
I entered a Date into a cell and Excel reformatted
it. Now how do I format the cell back to a number?
Each cell in Excel has a Format property that starts out with 'General'.
If you set a cell to a date, the cell format will be changed to a 'Date'.
If you want to change it back to a number, select the cell , right-click
on it, and select 'Format Cells'. Then select the desired format. Select
'General' to clear the format for the cell. You can set the format for
each spBasic variable name by selecting the variable value column and
setting the format as described above. You can set each individual cell
according to the variable display desired. Select 'General' to clear the
format for the cell. You can also set the format for an entire column
by selecting the column, right clicking on it, and choosing 'Format Cells'.
How do I wrap the text in a cell?
Right-click on the cell, select 'Format Cells', select the 'Alignment'
tab, then check the 'Wrap Text' checkbox under 'Text Control'. You can
wrap the text for an entire column by selecting the column and formatting
it as above. This is automatically done when you create an spBasic program
column using the spBasic menu.
Can I use another text editor to write or modify
an spBasic program?
Yes. The SpBasic Edit Form has a built-in editor, or you can use your favorite
text editor.
I use a single quote in front of
a workbook name as a variable value, but I get an error.
The single quote is dropped by Excel before the term is evaluated. Put
two single quotes before workbook name, one will be dropped but the other one will be valid. See What's
the story with the single quote character in Excel? below.
What's the story on the single quote
character in Excel?
Excel stores cell values as Variants, and the value type is determined
by the content. If the first character of a cell is a single quote ' ,
the rest of the cell is interpreted as a string, so you can make a number
a string by putting a ' before the number. The ' is not displayed but
it is there when you edit the cell. If you use a book or sheet name that
contains blanks in a variable value cell, or any other cell value, put two single quotes before the book or sheet name, or the single quote will be dropped and
statements using the variable or cell value will fail. The single quote in the first character of a
cell tells excel that you want to interpret the rest of the cell as a
text string and it is dropped before the term is evaluated. If you have two single quotes, the first one will be dropped but the second one will be valid.
When do I use double quotes in spBasic?
When to use double quotes, e.g., "myString",
1) You don't have to use quotes in spBasic variable
value cells (the cells to the right of the variable names). The cell contents
will automatically be interpreted as a string without having to use quotes.
If you put quotes in, the quotes will become part of the string.
2) Use quotes in spBasic statement expressions where
a literal string is needed, e.g, astr = "Hello"
3) If you want a number to be a string, you can
a
- put a single quote mark ' before the number
b
- reformat the variable value cell (the cell to the right of the variable
name) to 'Text' format. Do this by selecting the cell, right click on
it, and chose 'Format Cells'. Then select the 'Number' tab, select 'Text',
then press OK.
Some of my Excel expressions do not work when
I use spBasic variables.
Make sure the spBasic variable value cells (the cells to the right
of the variable names) are formatted as 'General'. If they are
formatted as 'Text' you may get errors. See the question above for how
to reformat a column. You can also reformat individual cells by just selecting
the cell.
Error Messages
I get the message "Programmatic Access to Visual Basic Project is not trusted" when I try use the spBasic menu. What's wrong?
If the
'Trust access to Visual Basic Project' setting is not right, you will get the following error window,

You have to set the Excel 'Access to Visual Basic Project' macro security settings. For Excel 2003 Instructions, click here. For Excel 2007 Instructions, click here. Select the 'Trust access to Visual Basic Project' checkbox. Then exit Excel and restart it. This will eliminate the message.
I get a message "The following features cannot be saved in macro-free workbooks" when I exit Excel 2007

You are trying to save the workbook in Excel 2007 as a ".xlsx" macro-free workbook. To use spBasic with Excel 2007, you must save your Excel worksheet as either a Macro-Enabled '.xlsm' file or as a Excel 97 - 2003 Format '.xls' file. Saving as a '.xlsx' file will not work since this format will not allow macros. When you create a new worksheet, the first thing to do is click on the Office Button on the upper left and choose "Save As -> Excel 97-2003 Workbook (*.xls)" or as a Macro-Enabled (*.xlsm) file and save the workbook. It's recommended that you use the Excel 97-2003 Workbook (*.xls)" format for backward compatability.
I get a "Error in loading
Dll" message when I install the SpBasicAddIn.xla. What does this mean?
You may get this error message when you install the SpBasicAddIn.xla
for some versions of Excel. Ignore this error if it appears, it will not
affect program operation.
I keep getting 'Invalid Statement' errors
in some Example program statements I'm using.
If the syntax of the statements are correct, make sure you have the proper
spBasic AddIn installed in Excel which runs the statement. If the statement
isn't included in the Help statement list, the AddIn which includes the
statement you want is probably not installed. See the sbBasic installation
instructions on the Downloads page for info
on how to include an AddIn in Excel.
I get a "Macro Disabled" message. What's wrong?
You have to modify Excel security settings. Select the menu item Tools
-> Macro -> Security. Set the security under the 'Security Level'
tab. Select 'Medium' or 'Low' security. If you use the 'Medium' setting,
Excel will ask you to enable macros each time Excel is run. If you use
this setting, make sure you select 'Enable Macros' each time you run Excel
or you will get an error message when you run an spBasic program. If you
don't want a security message to be displayed each time you run Excel,
select 'Low' security. You will be protected from unsafe macros if you
have virus scanning software installed (if you don't, you should). Also,
never download and run any workbooks that you don't trust.
After modifying the security settings, exit Excel and restart it.
When I click on an spBasic Form, I just get a 'Beep'and nothing happens.
This will happen if Excel is in the Edit mode (flashing cursor in a cell). Click on another cell to get out of the cell edit mode. This also happens if Excel is displaying a Message Box or other form which is waiting for an input from you.
You have to be careful when you're using the spBasic Edit Form with the 'Keep On Top' checkbox checked. If Excel has a message it wants to display, and the Edit Form is in the center of the screen, the message form may be behind the Edit Form and you can't get at it, and you'll just get a 'beep' when you click on the Edit Form. The best thing to do is keep the Edit Form off to one side, so any Excel messages can be displayed in the center. If a message form does get behind the spBasic Edit Form, press 'Enter' or 'Esc' to respond to the unseen message.
I get a "Excel not responding" or "Component
Busy" error. What does this mean?
If Excel is in the Edit mode (flashing cursor in a cell), you get a "Excel
not responding" or "Component Busy" error. Click on another
cell to get out of the cell edit mode.
SpBasic Forms and Windows
How do I add a statement to the last line of
Help 'Favorites' Group?
If you want to add an item to the bottom of the Help Favorites list,
1) Go to the Favorites group and select the top line in the
list window.
2) Go back to the statement from another Group that you want
to add.
3) Right-click on the statement and select 'Add to Favorites'.
If you don't select the first item in the Favorites list, the statement
will be added before the selected line in the Favorites Group.
Charts
I get a "Chart Formula" error
when I try to display certain charts.
When you collect and display data, the Chart should have at least 1 data
point or you may get a 'Chart Formula' error. When you create a Chart
with spBasic, if the first data point is blank, a '0' is inserted in the
first data point to avoid this problem. If you clear the entire data range
before you start taking data you may get this error. To avoid this, leave
the first data row uncleared.
Can I copy a chart into a worksheet?
If you generate a chart on a separate chart sheet, you can copy it and
paste it to another sheet and it will be embedded in that sheet. You can
resize it, change the title fonts, etc.
I've created a "Strip Chart" using
the 'Create Chart' menu. When I select the "Run" option on the
chart, only the last part of the data points are displayed, not the beginning
data points.
In the 'Run' mode, before collecting data to be plotted, you want to clear
the data cell range column except for the first data entry (Excel Charts
must have at least one data entry in a data column).If you don't clear
the data after the first point, the old data will be displayed and the
new data won't appear in strip-chart format.
How do I find the chart name for a Chart
embedded in a worksheet?
To get the name of an embedded chart, select a cell on the worksheet (don't
select the chart), then press Cntrl and click on the chart. The name will
appear in the 'Name Box' in the upper left of the Excel window.
I can't access a Chart series collection from
VBA
The series collection on a chart can be accessed from VBA code only
if if the cells contains data. If the cells are blank it will give an
error. If the series doesn't change, it's because the series data is blank.
The data on the "Strip Chart" disappears when the chart data worksheet is changed
The worksheet name is invalid in the "X Axis Range" or "Data Value" cells, or, if the worksheet or workbook contains blanks, you have to include two single quotes before the name and a single quote after the name. See What's the story with the single quote character in Excel? to see why you need two single quotes before the name if it contains blanks.
VBA and spBasic
How can I run a VBA Macro or VBA Subroutine form
spBasic?
See the Developer's Page
-How to use VBA with spBasic.
I have a Msgbox statement in a VBA macro I'm
calling from spBasic. While debugging the program the message box was
displayed behind the Debug Form and I couldn't get at it. I had to use
Ctrl-Alt-Del to stop Excel and start over.
SpBasic Windows will normally stay on top of the Excel window. Excel treats
VBA as part of it's window, so you have to be careful if you're
using a VBA messagebox or an input form at the same time that an spBasic
window is displayed. If you use a message box from VBA, and a spBasic window is showing (Edit Form. Help, etc.) , the msgbox might appear behind the window. Press ‘Enter’ or 'Esc' to terminate the msgbox and return control to the spBasic form. To avoid this situation, keep the spBasic windows off to the side when you're debugging a VBA routine
containing a msgbox or input form, or minimize the Edit form and create a Run button to run the program ( run the program from the ‘Run’ button).. This is also true for any Excel User
Forms that you may generate. Note for some versions of Excel, the spBasic
windows may not stay on top the first time you use spBasic after turning
on the computer, but they will stay on top if you close Excel and open
it again.
I'm using a VBA function that I wrote, but it
executes each time I add or delete a cell on the worksheet. What's going
on?
You probably have a cell somewhere on the worksheet that has a Function
inserted, and that function uses your VBA function. The cell value is
recalculated each time the sheet is updated, and your function is executed
during the recalculation. If you can't find the particular cell that's
causing the problem, copy the cells you want to keep onto another worksheet,
and delete the original worksheet. Make sure the cells you copy don't
use the VBA function in their formula's.
This problem can also happen if you are using cell functions from an Excel
AddIn. The fix would be the same as above.
I wrote a VBA function to use in an spBasic
program. I put a break statement in the function to debug it, but when
I trace through the function I get an spBasic error at the end
If you are writing VBA routines for use in spBasic, and you are tracing
the routine flow using 'break' statements in your routine, make sure you
press the 'Continue' button before you exit your routine. You can press
the 'Continue' button on or before the last 'Exit Sub' or Exit Function'
statement.

If you don't press the 'Continue' button before the last 'Exit Sub'
or Exit Function' statement, and trace the program (by pressing f8) after
the last 'Exit Sub', VBA attempts to trace the statements in the protected
spBasic AddIn's. This may cause the following errors,
- Error in Calling VBA Initialization Routine
- Application-defined or Object-defined errors
You will have to exit Excel and open it again. Remember, while tracing
your VBA routines, press the 'Continue' button before or at the last 'Exit
Sub' in your main VBA routine.
Protected Worksheets
I've protected a program worksheet
with a Password, but now I can't run any programs.
If a Password is use to protect the sheet, you must use the spBasic
'SetPassword' statement. It is not needed if a password is not
used. If a password is used, this statement must be the first statement
of the main program that is run. Also, all program sheets that are protected
must use the same password.
If subprograms are called by the main program, they don't need a 'SetPassword'
statement since it already has been set by the main program. Remember
that all protected program worksheets must use the same password.
The password must be set explicitly in the statement as a string, e.g.
SetPassword "myPassword". You cannot use a variable name to
hold the password. Also, remember to unlock all cells that you are changing
on non-program protected worksheets.
I've protected a program worksheet, and I'm
running the program from another worksheet, but now the second worksheet
flashes when I run the program.
You can reduce the flashing by hiding the program worksheet using 'Format
-> Sheet -> Hide'. To eliminate the flashing, put the program on
the active sheet (the sheet your running the program from). You can hide
the program and variable columns if you don't want the user to see them.
After hiding the columns you can protect the sheet. Remember to use the
'SetPassword' statement in the program (see the question above). Also,
remember to unlock all cells that you are changing on non-program protected
worksheets.
Add-Ins
I deleted an addin and added another
addin with the same name, but when I open Excel, the old addin is still
there.
To Delete an Excel Add-In and then add an Add-In with the Same Name,
1 - Delete the old add-in from the add-in list. Save the file and exit
excel.
2 - Add the new Add-in using the Browse button
In some Excel versions, if you don't follow these steps, the old Add-In
will be used.
Instrument Control
When I put my computer in Standby to save power, and Excel is open, I loose my instrument connection
This can happen with some communication hardware and/or software. To avoid this, set the power options from the 'Start -> Settings -> Control Panel -> Power Options'. Select the 'Power Schemes' tab, and set the 'System Standby' option to 'Never'. You can also set the 'Sleep Button' under the 'Advanced' tab to 'Do Nothing' if you don't want the sleep button to break the instrument connection.
I get a timeout error while running
a RS-232 serial interface on my Dmm after I send a SCPI command string.
Any suggestions?
You might have to add a 'WaitMs 300' statement after a SCPI_SendCommand
statement before you send a query. This will wait 300 millisec after the
command before the query is sent. Adjust this time as necessary for your
system.
I get a "Compile Error in Hidden
Module" when I try to run any Agilent 34401 or Dmm statement in my
program.
Make sure you installed 'VISA COM' on your machine. See the installation
instructions in the Downloads page.
I get a error when I try to use a resource
string such as "GPIB0::8::INSTR" or "ASRL1::INSTR"
in a statement in my program.
Make sure you installed 'VISA COM' on your machine. See the installation
instructions in the Downloads page
|
Live Excel Help!
Free initial talk time, no charge until you're convinced that the expert can help you!
|