Running A Macro When A Cell Value Changes
Hi hope somone can help...
How can I get a macro to run when the value in cell b1 changes. Cell B1 contains a data validation list, and when this changes i want the spreadsheet to update its self.
Any ideas would be appreciated.
Many Thanks
Robin
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Running A Macro When A List Boxes' Link-Cell Value Changes
I need a macro for a single spreadsheet that activates when a specific cell value changes. The cell is the "link cell" of a pull-down list box.
I have tried the following...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not IsEmpty(Target.Value) And Target.Address = "$H$33" And Target.Value <> 2 Then
Range("H33").Select
TValue = ActiveCell.Value
If TValue < 2 Then
MsgBox "Note: Office referral is required!"
End If
End If
End Sub
Unfortunately, this script does not work because the spreadsheet-user is not actually clicking on cell H33 and explicitly entering a value and hitting hitting the <ENTER> key. They are using a pull down box which records the value in the target cell without any selection being made.
I've also tried creating a macro that I assign to the pull-down box so that anytime the list box is used and an item is selected from its list, the macro is invoked. The problem here is that the macro is invoked before the list's item is actually selected. In other words, the order of events on this method is (1) List box selected, (2) Macro invoked (3) Link-cell value is updated. My guess is that if the link-cell value was updated before the macro was invoked, this would work ... but alas, it doesn't. Can anyone offer a suggestion.
Select And Copy Just Cell Content (not The Cell Itself) By VB Macro
Hi,
my problem is that I can select the content of Cell in Excel sheet [by doubleclicking (or F2) onto the Cell and simply select the whole text inside] and copy it as text.
But I cannot do this by macro.
Is there any chance to select content and copy it by VB macro?
Openning Excel And Running Macro From Word - Macro
Ok - I have a DB which I export to Excel, I then run a macro to "Groom The Data". I then run word and run a Macro (MailMerge to print labels) which retrieves data from the excel spreadsheet groomed above. Everything is working fine, despite my novice knowledge of VB, but I would like to do this in a single click.
I use a command line shortcut to Launch word and automatically have it run the macro, but I still have to Launch Excel and manually run its macro first.
I did not find a command line switch to make excel launch and run a macro. Is there any way I can Lauch Word have its Macro link to excel, then launch and run the excel macros before performing the macro I have set up in word (mailmerge)
In Other Words I have working macros in Word and Excel, I want the Word Macro to force the Excel macro to run before completing the rest of its duties.
Thanks
WW
New Value To A Cell Through Macro.
Hey group. I need to import a new value to a cell through macro. How do I actually insert it in a cell once I have correct "A" ?
Sub Macro2()
Dim A As String
Dim B As String
'
Range("J2").Select
B = ActiveCell.Text
A = Replace(B, "/", "")
Range("H2").Copy Destination:=A
End Sub
Run A Macro On Cell Change
New at this but reasonably competent and have searched various threads & sites for 2 days and have it working but not in the proper fashion.
Using:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
' Look to see if Value in Cell 1,1 changes from 0
If Target.Value >= 1 Then
' Call the Macro contained in Module1
Call UpdateSPCResults
End If
Application.EnableEvents = True
End If
End Sub
Works great if you actualy type into the cell and press Enter. The problem is that $A$1 is populated via a DDE Poke from another app based upon an event within that app and it appears that the Worksheet_Change object is blind to that type of change.
When I manually change the contents of $A$1 my macro fires fine and pulls a ton of info from the app that feeds $A$1 - just as I need it.
Have a bridge around it using a macro that just fires every 15 seconds to see if there is a change but it really is a waste of resources - and not the right way to do it.
Thoughts, direction, suggestions? Willing to do the work just don't know where else to look. Thanks
Cell Formula From A Macro
I'm trying to insert formulas into cells from a macro in the R1C1-style. I can get that to work, but now I would like to add in a variable to the formula, it appears to work fine in A1 notation. Something like this works...
Code:
Dim somer
Range("B28").Select
somer = ActiveCell.Address
Worksheets("Dataform").Range("A30").Formula = "=IF($A$28<" + (Range(somer).Address) + ",1,2)"
But when I modify it like this
Code:
Dim somer
Range("B28").Select
somer = ActiveCell.Address
Worksheets("Dataform").Range("A30").FormulaR1C1 = "=IF(R28C1<" + (Range(somer).Address) + ",1,2)"
I get an error. I'm thinking it's due to how the cell address is being set in the variable but can't figure out how to do it correctly or if that's even the problem.
Help?
Excel: Using A Cell Value To Run A Macro
I've got a spreadsheet that is always open and watching live data from another program (WonderWare). I need to figure out how to use a cell value (which in this case is discreet, always a "1" or a "0") to run a macro. I have the macro written and it works, but it needs to run when the cell value changes. It only needs to run one time, but each time the value changes it needs to run.
any thoughts?
thanks
..Brady
Cell Range Naming In Macro
im getting my self into all sorts of problems in Visual basic and excel could anyone help with this
Code:
Dim Rg As Range
Sheets("Classes").Select
Range("A2:A500,H2:H500").Select
Set Rg = Selection.SpecialCells(xlCellTypeConstants, 3)
Set Rg = Application.Union(Rg, Selection.SpecialCells(xlCellTypeFormulas, 3))
Rg.Select
'
End Sub
the code above selects a range of cells. What would be the code to which it gives these selected cell a name. (Cell range naming)
Run Macro On Specific Cell Change
Is there a way to have a VB Macro run when a specific cell changes value ? I am able to have a macro run when a "sheet data change" takes place, but do not know how to isolate a specific cell to be watched, while ignoring any other changes to the sheet.
Thanks in advance for any help !!!
Activate Cell In A Searching Macro
Hi,
I try to make working this searching function (Quoted sub) with two simple functions I don't know how to implement. When the unique row (there will be never more than one row found) is found, I want the active cell to be "Worksheets("UE").Range("A" & this row found)" and I want to copy in a variable the number of the row we are in. I tried several thing but it seems not working as far as now. Any ideas?
Thx!
Werner
Quote:
Sub Acces_dossier()
Dim rngUEData As Range
Dim rngUE As Range
Set rngUEData = Worksheets("UE").Range(Worksheets("UE").Range("CHAMP_DÉBUT_BD").Offset (1, 0), Worksheets("UE").Range("A65536").End(xlUp))
Dim IDUform As Long
'Variable corresponding to the IDU from the form.
IDUform = Worksheets("Formulaire").Range("Y2").Value
Application.Calculation = xlCalculationManual
For Each rngUE In rngUEData
If Trim(UCase(rngUE)) = Trim(UCase(IDUform)) Then
'It's here I want to implement those function logically.
Sheets("UE").Select
'rngUE returns me the value of the Y2 cell, not the UE row cell place
Range(rngUE).Activate
End If
Next rngUE
Application.Calculation = xlCalculationAutomatic
End Sub
Assign Macro When Cell Is Clicked
I have a range of cells (say A3:E3). If the user clicks on any of these I want to bring up an input box. I don't know if I should use Worksheet_Change since I don't want them to manually put anything in the cell, but have it activate just by selecting the cell. Is there any sort of worksheet_click event?
Also, if I use ByVal Target as Range (or something like that), how do I test for the range of A3:E3 rather than just one single cell?
Thanks!
Run A Macro Based On Cell Change
Hello
I am trying to automate the write dde object based on cell change vs. doing it with a button that runs the macro to write dde object. what happens when I run the following code is nothing, no error, no message. As you can see I am using a message prompt to verify something is happening instead of running the ddepoke command.
this is in sheet 1 and in previous attempts I have used If with Else If and End If, as well as Select commands. those would at least error out telling me that "something" was happening now there is truly nothing happening.
Thanks in advance for any input that can be offered.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
' The variable KeyCells contains the cells that will
' cause a action when they are changed.
Set KeyCells = Range("$D$2:$D$4")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
End If
If Target.Address = ("d2") Then _
'isosp = DDEInitiate("rslinx", "AdjTankPSI")
'DDEPoke isosp, "N84:250", Cells(2, 4)
'DDETerminate isosp
MsgBox "you just adjusted iso tank" & Target.Address & " has changed."
ElseIf Target.Address = ("d3") Then _
'poly1sp = DDEInitiate("rslinx", "AdjTankPSI")
'DDEPoke poly1sp, "N84:251", Cells(3, 4)
'DDETerminate poly1sp
MsgBox "you just adjusted poly tank 1" & Target.Address & " has changed."
ElseIf Target.Address = ("d4") Then _
'poly2sp = DDEInitiate("rslinx", "AdjTankPSI")
'DDEPoke poly2sp, "N84:252", Cells(4, 4)
'DDETerminate poly2sp
MsgBox "you just adjusted poly tank 2" & Target.Address & " has changed."
End If
End Sub
Adding Cell Values In A Macro
I'm trying to add the values of two cells within a macro and then insert the sum into one of those cells.
Not sure what to use here.
I tired
Code:
Worksheets(strStation).Range(Cell7).Value = (SUM(Cell7:Cell8))
Where Cell7 and Cell8 are variables for the two cell locations I want to add together and then put the result in the Cell7 location. And that just gave me a compile error.
help anyone?
Goto A Particular Cell (excel Macro)
Hi,
I am working on an excel macro.
Is there a method whereby I can take the control to a particular cell in the current active sheet.
e.g if the control ( cursor) is in say cell C 10. when the user runs the macro the control (cursor) should go in cell S 22.
How can I do that.
amol
Looking Up A Cell And Changing The Contents In A Macro...
Hey all, hope you can help with this
OK, heres my problem:
Ive been making a Log in script in Excel using VB macros, and ive got as far as the user can register, log in, and it brings up his/her details like name, address, age etc. Now what im really stuck with is how to make it so the user can change their details. Basically what i need is the following, with my blanks filled in:
if Sheets(1).Range("cell with their name in") <> Sheets(1).Range("Cell with name stored in DB") Then
'the bit i dont know:
lookup their name in DB, and make it equal Sheets(1).Range"(cell with their name in")
End If
So the bit i dont know how to do is to make it so i lookup their name in the database (using something like a glorified vlookup, hope u can tell me what lol) and make that cell equal another cell of my choice...and this happens when one cell is not equal to another (when there name in DB is not equal to the name they change it to)
Any help will be greatly appretiated...ive been staring at it blankly for about an hour now *sigh*
Thanks,
Ross
From Macro Write Text To Cell
I'm using checkboxs on a form, calling it from a macro and then based on the choice a number gets written to a cell.
Looks like this.
Code:
If ChooseCCOutput1.cc1 = True Then
Worksheets("work").Cells(4, 2) = 8
Unload ChooseCCOutput1
ClosureAssign
End If
Here I'm putting the number 8 in the cell. In a different section I would like a text string to write to the cell instead based on a choice from a form. Just putting the text after = doesn't get it. Can someone tell me what I should do instead?
Thanks!
Excel - Run Macro When Cell Selected
Anybody know if and how I can start a macro whenever I select a cell, any cell? Thanks.
What I want to do is display the cell's value, similar to the way a comment would be displayed. The cells currently contain formulas.
Thanks.
Excel Macro-image To Cell
I need to create a new toolbar button that when pressed will insert a tiff image into a cell within Excel 2000. I know how to create the toolbar button and how to apply the macro but I need the VB code .
Thanks
Macro For Renaming Worksheet With Cell References
I'm trying to write code to rename a worksheet with two cell references. I'm able to do one cell reference, but can't concatenate the other. Can anyone help? This is what I have for one:
ActiveSheet.Select
ActiveSheet.Name = Range ("A1").Value
I want to cconcatenate the value in A1 and B1 and parse if it's over 31 characters long. It seems as if it should be simple, but I've come to a sudden stop.
Thanks!
Trigger Macro On Change Of Linked Cell
I have a Excel VB Macro which triggers on any change to a specific cell, however it does not trigger if the cell value is "linked". That is, if the target cell is A1, and it is linked from A2, changes to A2 do not trigger the macro. Is there a way to get the macro to look at a "linked" value of A1, and not the formula itself ? Thanks...
Force Size Cell Dynamically Via Macro.
Hi,
I have the problem to fill a cell with a data string that change in length. I have set the "Wrap text" attribute for the cell but the size of the cell do not change dynamically. I'm using a macro to fill the cell. Is it possible to force this condition via macro o to solve this problem?
Thanks in advance for your help.
Regards,
Giovanni
Execution Of Macro When Contents Of Cell Changed?
Hi,
i have a question regarding execution of macros. Can i execute a macro only when contents of one particular cell in a worksheet are changed?
I know that i can execute macro anytime when the contents of the whole worksheet are changed but i think that in my case it would wasteful, because i need to execute a macro only when the contents of one cell are changed!
Gatis
Reading The Contents Of A Cell (excel Macro)
Hi,
I am working on an excel macro.
How can I read the contents of a particular cell ???
e.g my active cell is say C 3 . and i want to read the contents of cell
F 5 .
How can I do that
amol
Turning A Excel Cell Into A Button With Macro?
Hi I wish to turn an Excel cell into a button, but the Google results does not seem very promising. Is it at all possible to create a proper button in a cell.
Normal or straightforward methods do not seem to work. Can anyone tell me where to start or confirm that it's just not impossible?
Excel Macro - Cell Coordinates For Window
I would like to automatically move a userform if it is covering the active cell in Excel. I know the coordinates and bounds of the userform relative to the Excel application window, however, I do not know how to access or calculate the active cell's position relative to the application window. I know the active cell's position within a pane, but to that I need to add offsets for row headers, column headers, pane dividers, and command bars.
Does anyone know how to do this? Is there a straightforward way to determine the position of the active cell within the application window or do you have to calculate it piecemeal?
John
Capturing Cell Contents For Insertion Into VB Macro
ITtoolbox visualbasic-lHello all,
I am trying to capture the contents of a cell and insert them into my text file creation macro. I hope I have given enough information without making this too abstract to understand.
For example, Cell X1u01
This is a hypothetical node number that I wish to be used as part of a long list of output filenames for a total of 14 nodes (about 15 files per node) such as:
7501-router1-config.txt
7501-router2-config.txt
7501-router3-config.txt
7501-switch1-config.txt
7501-switch2-config.txt
7501-firewall1-config.txt
7501-firewall2-config.txt
so if I use Range("X1").Select, What is next to insert that value into the following
DestFile = "C:TFTP-Root" & Node2 & "Node2_NT2SW.txt" Where "Node_2" is the contents of cell X1 (7501).
so that the resulting file is "c:TFTP-Root75017501_NT2SW.txt"
Absent my rookie abilities (I had never written in VB until about 3 weeks ago) to perform this seemingly simple task, I have written many extra subs with text input boxes for the user to re-enter the node names, creating the text file names that way.
Public Sub NodeNames1()
' Prompt user for destination file name.
Node1 = InputBox("Please Enter the 4-digit Team Label for Node #1:" _
& Chr(10) & "(Example 6319):", "Node#1 Label Required")
If Node1 = Cancel Then
Application.Run "InterimCancel"
Else: Application.Run "NodeNames2"
End If
End Sub
Public Sub NodeNames2()
Node2 = InputBox("Please Enter the 4-digit Team Label for Node #2:" _
& Chr(10) & "(Example 6320):", "Node#2 Label Required")
If Node2 = Cancel Then
Application.Run "InterimCancel"
Else: Application.Run "NodeNames3"
End If
End Sub
etc...for 6 nodes. "Interim Cancel" is simply an abort mechanism if the user realizes a mistake was made.
EXCEL: Execute A Macro When A Cell Is Clicked
How can I select a cell in Excel and cause it to activate a macro? I also need to know what the range address is of that activated cell. The macro will open up a userform where the user selects an item and the first column value will be placed in that active cell.
I think I'm in over my head...
How Do I Get A Macro To Select A Cell Depending On Another Cells Data
this problem may be a simple one but as im not very good in visual basic i cannot think of a function to use.
here is an example of my problem.
I have a cell number in one cell.
Cell G1 has the data D5 in it.
And i need a macro to select cell D5 by using the info it found in cell G1.
Sorry if that isnt very clear but i cant think of any other way of explaining it. please help.
Macro To Calculate Cell Values Not Working On Decimals
Hi guys,
i've got the following bit of code to cycle through the sheets of a workbook and calculate the total vlaues for each column and then place the value in the corresponding cells on the master sheet. The code is simple but I can't see why it won't yake values such as 0.5 into account. Even changing the format to increase the numbers after the decimal place has no effect.
cellTotal and currCellValue as both declared as Double
For Each sheet In sheetNames()
If sheet <> "" Then
Set currSheet = baseBook.Sheets(sheet)
currCellValue = currSheet.Range(cellAddress).Value
cellTotal = cellTotal + currCellValue
'place cellTotal into cell in month sheet
monthSheet.Range(cellAddress).Value = cellTotal
If cellTotal > 0 Then
monthSheet.Range(cellAddress).Interior.Color = RGB(200, 200, 200)
End If
End If
Next
any ideas?
Cheers, Jo
How To Let A Macro Only Print When A Cell Refering To A Dropdownlist Is Filled?
Hello,
I have a problem. I have created an excel file which has a dropdownlist to simply retrieve data from the database.
The dropdownlist is made up by numbers. Each number belongs to a group.
example:
numbers
100, 109, 104 & 107 belong to group 1
105, 106, 111 belongs to group 2
I now want to create a macro, which prints out all the output for the group that belongs to the number.
In other words: when I select for example number 100, I want the macro to automatically select number 100, 109, 104 and 107 and prints it's output.
I've already created a column with the following function
=IF(BQ1=$G$4;BO1;"")
This function searches for the groupnr of the selected number, and then compares is to the others. When they have the same groupnumber it's number is shown.
I think this should be used as input for the droplist, after which excel automatically prints them out.
Because of the difference in the group's sizes, and can't just set a static range to be printed out...
Can anyone please help me?????
Excel Macro Performing Web Query - URL From Worksheet Cell
All
I wonder if anyone can help me with the following, please:
I'd like to use a macro to perform a web query on a URL, but rather than specifying the URL in the code, the macro picks it up from a cell on a worksheet. For example, if cell A1 on Sheet 1 contains "http://www.google.com", and I want to display the web page on Sheet 2, my attempt at the code is;
Dim myURL
myURL = Worksheets("Sheet1").Range("A1").Text
Sheets("Sheet2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & myURL, _
Destination:=Range("A1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SaveData = True
End With
It seems to stop on the ".Refresh BackgroundQuery:=False" line - any ideas on this at all, please? I assume this can be done?
Also, if it's possible to specify the target URL in a message box, that would be ideal.
Thanks for your time, all suggestions much appreciated!
Neil
Running A Macro Sub
I am trying to create a sub that will run for an Excel file. For example:
Private Sub Wheelbase_Range_Click()
Set objExcel = CreateObject("Excel.Application")
Set objBook = Excel.Workbooks.Add
Set objSheet = objBook.Worksheets(1)
Enter Worksheet data here
objWorksheet.Run "Sub Macro1()" (This is where the error occurred)
End sub
Sub Macro1()
Contents of Macro 1 here
End Sub
There is more to the program, but these are the important parts. Any suggestions on how to run this Macro Sub for excel?
Thanks in advance,
Mark
Running A Macro
When I use macros I have only used them for Automating process with Excel.
My question is, how do I make it run a different program...
Example is: Opening up Internet Explorer, and playing a game written in java script (like astroids or something)
I know how to do key strokes, but I know nothing more for making run a program outside of ExCel
Running A Macro From VB6
Hello Everyone
This is time i am almost near to complete my project .. so far what i have done is extracted required information from a text file ,created an excel file and stored that information in sheet of excel ( with the help of VB6 form ) . now i have a macro and i want to run this macro on that very sheet of excel file , can i do it with help of VB6 ?
assume that i have my macro in a text file "macro.txt" at same path .. though i can include that code of macro anywhere in my vb6 code .. and i want to run it on sheet "Results" of Excel workbook "Working" .. placed at same directory .. how would i proceed . a lil code will be appreciable .. rest i ll try to understand though ..
Regards and Waiting
Running A Macro ???
Hi,
I have written a macro in MS Excel. I want to run it as soon as the file is opened by the user. How do I do it?
Kinjal
Macro Running Once
I've got a column of dates which a want to individually change colour depending on the current date. However, I only want the macro to run once on loading of the the worksheet - is this possible, how can I stop the end of the column becoming the active cell and is my code reasonable efficient?
TKS
Louise
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
Range("b4").Select
Do Until ActiveCell = ""
If ActiveCell > Now() + 121 Then
Selection.Font.ColorIndex = 5 'Blue
ElseIf ActiveCell > Now() + 30 Then
Selection.Font.ColorIndex = 3 'Red
ElseIf ActiveCell < Now() Or ActiveCell <= Now() + 30 Then
Selection.Font.ColorIndex = 1 'Black
End If
ActiveCell.Offset(1, 0).Range("a1").Select
Loop
End Sub
Running A Macro In Vb
I 'm trying to open a report in vb from a command button tha triggers a macro in access. The command button says to open ru a macro that opens a report. I'm Running Win XP professiona and is in an access 03 file format. When I click the comman button in the VB project. the database is locked exclusively but does not display the report or open access. This was workin for me in a access 97 format, but now I have upgraded to a newe version of access and it is not responding. Any suggestions? Di not change any references that I know of.
Code I use:
Private Sub mnuReport_Click()
Dim objAcc As Access.Application
Set objAcc = New Access.Application
objAcc.OpenCurrentDatabase ("t:sergeydb2.mdb")
objAcc.DoCmd.RunMacro "JCMacro" ' ["test" is a macro which open up a report"]
objAcc.DoCmd.OpenReport ("JCFORM"), acViewPreview
End Sub
Running A Macro Through VB
I am building a VB application which needs to automate aome processes of ER studio. I am using teh automation interface of ER studio to do this.
Now i need to run a macro (.bas file) that is located in a particular directory.
Can someone suggest me a way to run this macro either by using the ER studio automation interface or any other way which uses commands outside teh scope of ER studio.
Note: I know the location of the .bas file.
Thanks!
Running A Macro
Hello all,
I'm having a tough time initiating a macro. My senario is as follows:
Private Sub CostAll_Click()
End Sub
Private Sub RSFCOST_Click()
End Sub
I want the first macro (Cost All) to be able to run the RSCOST macro. Essentially I have 4 unique macros on a sheet that each perform a seperate function, but there are cases where it would be easier to have 1 button click perform all the macros, so I'd like to just have that one button run all four unique macros.
I just can't seem to get the syntex to be right, I think it has something to do with the Private location of the macro(s).
Your help is greatly appreciated.
Adam
Problem Accessing A Merged Cell In A Word Table Using MACRO
Hi ,
I am writing a macro which converts a MS WORD table into particular format. I need to retain the structure of the table while doing so.
The main problem is that if a row consists of a merged cell then there is no means to identify this at runtime. If a merged cell has occured in the input table i need to place a identifier for the same in the output....
Could anyone please let me know how can i achive this ?
Thanks
Excel Macro For Converting Text Formatting In Cell To HTML
Hi,
I'm new to excel macros and VB.
Would anyone have a macro (or hints on how to make one) for converting text formatting in a cell (in an excel spreadsheet) to html. that is, bold and italic and double enters to paragraph changes; for example i'd want a cell containing
"
lorem ipsum dolor
sit amet
"
cointain the following
"<p>
<b>lorem</b> <i>ipsum</i> dolor</p>
<p>sit amet</p>
"
after running the macro in the selected cell(s)
Worksheet_Change Running For Every Cell On Open.
When opening the file, the worksheet change runs for every cell. But it does not use the saved values in the worksheet, it runs while the values are empty. I have a function that clears a few things if the used deletes the value in certain cells. Each time I re-open the file, these values are being reset.
Is there a way to know if this is "onOpen" or some other way to stop this???
Error In Running Macro From VB
Hi I am new to the forum and hoping someone can help me out. I am pretty experianced in writing VBA macros and fairly new to VB but picking it up well. I want to be able to run a program that opens a .csv and runs my macro (which I know works and have been using for a long time) which is in an add in, but I want it to run in the back ground with out the user knowing Excel has opened.
Here is the code I have:
Dim obExcelApp As Object
Dim obWorksheet As Object
Dim obfile, obmac As Object
Dim blnRunning As Boolean
'Trap errors
On Error Resume Next
'Set Excel Application reference
Set obExcelApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set obExcelApp = CreateObject("Excel.Application")
blnRunning = False
Else
blnRunning = True
End If
'open .csv
Set obfile = obExcelApp.WorkBooks.Open("c:corp.csv")
'run macro
obExcelApp.WorkBooks.Open("O:HomeSpivonkaDevelopmentToolbarMacroT oolbar.xls")
obExcelApp.obfile.Select
obExcelApp.Application.Run ("Interactiveaddsheets")
When it get's to the Call portion I get an error that "a workbook must contain at least one visible worksheet"
Any suggestions? My final goal is to be able to call the macro from a batch file or something similar
|