Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Add Macros In Excel Sheet?

I want to write a Macro on Excel Sheet which should open a user name & password form made in VBA. I have made the form in VBA & trying to link it with a macro, but the macro is not working on excel file load? How should I do this.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Add Macros In Excel Sheet??
I want to write a Macro on Excel Sheet which should open a user name & password form made in VBA. I have made the form in VBA & trying to link it with a macro, but the macro is not working on excel file load? How should I do this.

Opening An Excel Sheet Which Contains Macros
Visual basic 6.0
During opening an excel sheet which contains macros a pop-up window ask you to select to enable or disable macros.
In a visual basic program which opens such file to read or write data, how can I make the program to select automatically from the pop up window to enable or disable macros or to close the pop up window in order to complete data reading or wtiting?

How Can We Enable Macros On Excel Work Sheet Automatically??
How can we enable macros automatically on Excel workbook's opening, without asking user for his permissions to enable the macros option? I don't want to set Macro level through Security in Macro, because it is only for the system where I have used it. what about the other systems? if I have to use it on anyother system.


How To Make My Macros Consistently Show The Same Area Of My Excel Sheet On The Screen
This is what I'm doing...
I'm using a Main Menu-type sheet in Excel so that the user of my spreadsheet can navigate it easily. The vba macros I have written search the spreadsheet for the date and selects the cell to start entering data. What I want is to make it so when it selects the date column, on the screen you can see 3 columns before the date, any number of columns after, and the top row on the screen is the row containing the header for the section. I've already tried selecting the cell and then scrolling but it was too inconsistent to work. I also have tried selecting a range of rows and columns and then zooming to fit selection. This works but I'd prefer to do it the right way. I have no manuals or books for vba and the help file is useless so I would really appreciate any help. Thanks.

Save Sheet Without All Macros

I have a workbook with macro, but when I save it again I want to save it without all macros (like Microsoft Excel Sheet file)! How can I do that?

Thank you

Importing Data From One Closed Excel Sheet Into Another Open Excel Sheet
Dear all,
   I am VBA newbie ... I need your help in importing the data froma closed excel document into another excel document.

Please help.

Concating Data Of More Than One Excel Sheet To One Sheet In The Same Work Book

I want to concate data of sheets in to another sheet in the same work book through VB.Please help me

VB In Excel - Trying To Display Cells From Sheet To Sheet.
I'm going to go ahead and appologize for asking this, but I have no idea where to even start to search.

What I am trying to do is run and excel macro that will look for an specific enrty in column A. The entry it is searching for can happen multiple times. I want it to then display the information in columns B-F, respective to the the criteria in column A. (If the search is met in column A, that row I want displayed on a new sheet within the workbook)

I'm pretty sure that I can get info to display from one sheet to another. But my problem is how to run the loop so that it will search column A, and dipslay all respective information in columns B-F, if their column A meets the criteria. And stop when it gets to the bottom of the data, obviously.

Any help is so much appreciated. Also if you could just refer me to another section/topic, that will work too. Thanks in advance.


One Excel Sheet Monitoring Another Sheet's Events
I've written some macros that open an excel workbook and when an account number is typed into a user defined cell or cells the name associated with that account number is plugged into another user defined cell from the workbook the macros opened. I think my co-workers would find these macros very useful, the problem is none of them are very computer literate, and I don't want to have to go around and set these macros up on their excel workbooks. I would like to have these macros stored in a single sheet, but be triggered by the events of the sheets created by my co-workers without them having to insert any code into the sheets they create... just insert the sheet with the macros. Does anybody know if this is possible?? I appreciate any of the help I can get!!! I'm getting frustrated!!!

Need VB Code To Insert A Row For A Subscripted Line In Excel & Code To Search For Amounts On One Sheet And Apply Them To Certain Area On Another Sheet
I am in the process of developing an Excel spreadsheet and need assistance
in adding visual basic code to automate it.

The first thing I am trying to do is to create a macro where a user can
click on a certain button, and the program will insert a row at a specific
row and will copy all formulas associated with the row above it. For
instance, if you have a spreadsheet that has 10 rows and 3 columns in it,
you can insert a subscript line below row 5 and call it 5.1. When the
subscripted row "5.1" is added, it will include the same formulas as in row
5, which would add columns 1 and 2 in column 3.

The second thing I am trying to do is have some code that if a user enters
information on Sheet B that needs to also be included on Sheet A, the code
will search Sheet B to see it an entry made on Sheet B should be carried to
a particular row in Sheet A.

I would greatly appreciate any feedback anyone can give me regarding this.
Thanks in advance.

Is't Possible To Put "Data" In Excel Sheet Or Value In DBGrid On Excel Sheet
I would like to Export Table .mdb connect with Data1 to an Excel Sheet. Is't possible with VB code?

Second option I have the same data in DBGrid is't possible to put Data in DBGrid on Excel Sheet.


Excel Macros - A Little Help Please
Hello People,

Attached is my problem. Hope someone can help me out.


Excel VB Macros
Is it possible to get an excel macro to tell Access to run one of its macros ??

Help In Excel Macros
I have this macro which I know is written very sloppy and I was wondering if there was any way to clean it up to make it run faster. Thanks.

Sub format()
PrevCell = ActiveCell.Address 'Remembers the cells that you had selected before you ran the macro

''''Very Sloppy code to scan all the used cells for values that are less then 10 characters in length
For x = 6 To 85
bob = Range("a" & x)
Range("a" & x).Select
If Len(bob) < 10 Then
Range("a" & x).HorizontalAlignment = xlCenter
Range("a" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("b" & x)
Range("b" & x).Select
If Len(bob) < 10 Then
Range("b" & x).HorizontalAlignment = xlCenter
Range("b" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("c" & x)
Range("c" & x).Select
If Len(bob) < 10 Then
Range("c" & x).HorizontalAlignment = xlCenter
Range("c" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("d" & x)
Range("d" & x).Select
If Len(bob) < 10 Then
Range("d" & x).HorizontalAlignment = xlCenter
Range("d" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("e" & x)
Range("e" & x).Select
If Len(bob) < 10 Then
Range("e" & x).HorizontalAlignment = xlCenter
Range("e" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("f" & x)
Range("f" & x).Select
If Len(bob) < 10 Then
Range("f" & x).HorizontalAlignment = xlCenter
Range("f" & x).HorizontalAlignment = xlLeft
End If
For x = 6 To 85
bob = Range("g" & x)
Range("g" & x).Select
If Len(bob) < 10 Then
Range("g" & x).HorizontalAlignment = xlCenter
Range("g" & x).HorizontalAlignment = xlLeft
End If
''''</Sloppy Code>

Range(PrevCell).Select 'Returns to the cell you had selected before you ran the macro
End Sub

Excel - Macros And VB
Hello ppl!

Well, I got the following problem and I wonder if there is anyone that could help. So, here is the situation:

I got an Excel spreadsheet with some values in it....some of those entered manualy by me and the rest calculated by formulas. What I need is to create a macro that could do something like "loop".

i.e the results in cells I19 - I21 and I23 to be replaced by the results in cells I41 - I43 and I45 respecrively. And I want this to be done until I19=I41.

Does anybody have any ideas?


Macros In Excel
I need help with creating a Macro that will look into a rang of cell and when the value is found to update data in a range of cells,


I will be using A1-D1 to enter information,
B1= Birth date
C1= Address

The inforamtion that was entered in A1-D1 should be located in the data that is already entered from Cell A10-D300, lets say after the data has been entered in A1 has the name JOHN in A1, after JOHN is found in the list that is from A10-A300, for example JOHN could any in A54 we need to update JOHN's inforamtion thats is B=54, C54 AND D54.

Is there a sample or temppate I can look into for assistance. I am pretty fresh in Macros in excel,



Macros In Excel Using VB
Hi Everyone,
I created a Macro in Excel now I am trying to edit and am hung up on a few things.

How do i make it so after it comes back with the text in my program, how to compare that text to something, then keep going?

I am using a program called Extra on a Emulated terminal program.

Also, cant i just use VB6 and do all of this, instead of using it in the excel spreed sheet?

Here is my test code:

VB Code:
Private Sub CommandButton1_Click()GetModelFileInformation' Run the Function belowEnd Sub  Sub SendCommandKey(Key As String, Scr As Object)' This Procedure sends a command key, like <enter> or <Pf3> to the Screen and then' waits for the host to finish updating the screen    Scr.SendKeys Key    If Scr.WaitHostQuiet(10) = False Then        MsgBox "VISION is stalled", vbCritical, "Alert"    End IfEnd Sub  Sub GetModelFileInformation()'Vision Screen# 1 - Function = Inquiry ' create variables    Dim Sys As Object, Sess As Object, Scr As Object    ' ready extra for information exchange    Set Sys = CreateObject("EXTRA.System")    Set Sess = Sys.ActiveSession    Set Scr = Sess.Screen ' Check Vision if New Part or Existing Macro' Macro recorded 3/28/01 by spl3792'    Do While ActiveCell.Value <> ""        Scr.MoveTo 6, 2        Scr.SendKeys "<EraseEOF>"        Scr.PutString ActiveCell.Value, 6, 2        SendCommandKey "<enter>", Scr        Scr.WaitHostQuiet 30        ActiveCell.Offset(0, 1).Value = Scr.GetString(6, 27, 24)        ActiveCell.Offset(0, 2).Value = Scr.GetString(6, 58, 2)        ActiveCell.Offset(0, 3).Value = Scr.GetString(23, 8, 40)        ' here is where i want it to check the value returned.        If ActiveCell.Offset(0, 3).Value = "INVALID FUNCTION FOR THIS OPTION" Then            ActiveCell.Offset(0, 4).Value = "Joe Fox Test"        End If                ActiveCell.Offset(1, 0).Select             Loop  End Sub

Excel And Macros
Im trying to use:

VB Code:
Sub highlite()     If Range("V" & Int(Rnd * "10000")).Select Then    Rows(Int(Rnd * "10000") & ":" & Int(Rnd * "10000")).Select    Range("F" & Int(Rnd * "10000")).Activate    With Selection.Interior        .ColorIndex = 39        .Pattern = xlSolid    End With    End If    End Sub

in excel, to highlight a whole row, if i click on a cell in that row, then if I click on another row, it de-highlits back to how it was originally and highlights the new row! what am I ding wrong and is there a solution?

Excel Macros
Is there a way to run an excel macro in vb.

Excel Macros
Hi all,

Never done macros in excel before so please bear with me...

How do you make a macro run automatically when you open the file the macro is on?


Excel Macros
Can you call a macro outside of excel..

Macros In Excel
Hi Guys,

I have a qestion about Excel and VB. I have an Excel file that has macros as part of it. My problem is that I want to know if there is a way of opening the workbook without asking the question about whether or not to enable the macros. I would like to macros enabed all of the time.

An alternative to this could be to copy the workbook to a second workbook and paste special all of the data from the first workbook to the second one. Is this possible through VB?


Excel Macros
Hi. Could anyone help me write some code for an excel macro that deletes every five rows in an excel spreadsheet?

Vba Excel Macros
how can u have a macro from one workbook run on another workbook? and run automatically at the same time everyday??

so the macro calls another workbook/sheet and the code runs on that sheet.

thank if u know!!

Excel Macros And VB
Hi all!!!

Is is possible to insert a macro from vb on a new excel file?

For example, I create it, fill it and, before closing if, I want to insert a macro on the file. Is it possible?

Another one: Can I execute a macro in excel from vb?

VB For Macros In Excel

Can anyone tell me how to do a repeat of a set of macro statements in VB in excel?

There are a bunch of calculations and commands in macros that I need to repeat for 5 different worksheets.

Another question is how to set array summation? For example, I'd like to sum a range in a column but the one limit of the range can only be referred to as a name because it is found through searching a column for some specific value.

Thank you so much if anyone can help.


Excel Macros! Help!!
Ok Medialint, I read a bit more in help (although i havent got help installed on this computer - i just looked it up in microsoft) and Ive overcome my first prob. now I need to figure out how to loop it. I dont think i can use any of my knowledge of java. do you know where I can find info on looping? I just need the solver to find parameters for all of the sets of x and y data.

Macros In Excel

I am not sure if this is the right forum to ask about Macros. If it's not, could someone please point me in the right direction?

I am trying to do what should be a simple macro, but I am hitting a brick wall.

I basically want this to happen: when a user types G in a cell, the cell turns green or if the user types R the cell gets Red filled and Y for yellow etc etc

Any help would be appreciated.

VBA Excel Macros
I've recently been thrown in at the deep end with VBA excel code. I'm working off a previous code, but i need to make some alterations.
I'm trying to change an Else statement to an external function, that i can call to from within the macro, and that i can also call to outside of the macro. The current code i wish to alter is:

Else ' If the row is valid data, search for its generic name.

' Check what is in the description column for the most common item types in order to give them generic names

' This next code will scan through a list of keywords on the second sheet. If that keyword is in the item
' description, the generic name associated with that keyword will be copied to the item line's generic name column, G (7) possibly should be F (6)

description1 = LCase(ActiveWorkbook.Sheets("Sheet1").Range(Cells(c opyto, 7).Address).Value)

For Each cell In ActiveWorkbook.Sheets("Sheet2").Range("c3:f162")

spaceBefore = cell.Value
spaceBefore = LCase(" " & spaceBefore)

spaceAfter = cell.Value
spaceAfter = LCase(spaceAfter & " ")

crntrow = cell.Row

If cell.Value <> "" Then

If InStr(description1, spaceAfter) > 0 Or InStr(description1, spaceBefore) > 0 Then

ActiveWorkbook.Sheets("Sheet1").Range(Cells(copyto, 6).Address).Value = ActiveWorkbook.Sheets("Sheet2").Range(Cells(crntrow , 2).Address).Value

End If

End If

VBA And Excel Macros
I would like to write macro to convert .txt file to .xls file. Basically, I wrote a batch file to run Ping Test for all the IP addresses. The output of all of them goes to another .txt file. I would like to make a report for all the IP address and status of its PING TEST. So, can any body guide me here?



Excel Sheet Question {excel Has Encountered A Problem And Must Shut Down}
I have a question on a form that transfers information to an excel sheet. What I have is a button that when you click it, it sends 4 pieces of information to an spread sheet. My problem is that it works just fine on my machine, but when I install it on a user system if I click it is said that "excel has encountered a problem and must shut down". It shuts down the excel program and my app. Can anyone give me a clue as to why this is happening?
Code use for this is:

Private Sub Excel_Transfer()
Dim sValue As String
Dim sValue2 As String

sValue = txtReqForm(2).Text ' assignes value in text box to string value
sValue2 = txtReqForm(5).Text

Dim oExcel As Excel.Application ' Sets up the excel transfer
Dim oWB As Excel.Workbook
Dim oWS As Excel.Worksheet

Set oExcel = New Excel.Application
oExcel.Visible = True ' Sets up excel sheet to be seen

' Dim oRng1 As Excel.Range

Set oWB = oExcel.Workbooks.Open(modMain.ExcelPath) ' Sets path for the excel document to open
Set oWS = oWB.Worksheets("Sheet1")

Set oRng1 = oWS.Range("A28") ' Sets range in excel cells to modify
Set oRng2 = oWS.Range("B28")
Set oRng3 = oWS.Range("F28")
Set oRng4 = oWS.Range("M28")

oRng1.Value = "1" ' Sets values for the cells to be passed.
oRng2.Value = "ea."
oRng3.Value = sValue
oRng4.Value = sValue2
End Sub

How To Call Excel From Vb And Save The Contents Of Excel Sheet In To Database
Hi folks

I want to retrive the details from Database to excel sheets.After displaying the data in excel sheets from Dataabse, let the user update the record the record and now the updated record should be saved in database

Enableing Macros In Excel
hello i have been given an excel file that my superiors want me to work on, the only problem is that i can not do it because every time that i try to see how it works i get the following error

"The macros in this project are disabled. Please refer to the on-line help ot the documentation of the host application to determine how to enable the macros"

i have tried everything i know to enable the macros but they won't work. can some one help me. i need to step through the macro to understand what is happening during the macro.

also is it possible to run a macro in Excel from VB6?

Multithreading Excel Macros
Hi all -
I am building a macro to pull data from a SQL Server and dump the results into an Excel Sheet. I have it all working fine, but some of the queries take 2+ minutes to run. When they are running, Excel is entirely unresponsive, as is the rest of the computer. The processing of the query is server side, so my macro is just waiting. I need a way to allow those queries to run while maintaining usability of the computer. I thought making threads within the macro might help, but when I try adding them in, it says that the User Defined Type is not defined. Does anyone know of any additional references I might need? Any other suggestions about how to do this?

Thanks much.

Macros: Lotus 1-2-3 To Excel
/reCurrent Period:H14..Current Period:H18~ Clear old exchange rates

Hi Peeps,

Above is a line of Lotus macro code. Can anyone tell me what the equivalent line of code in VB will be?


Lotus 1-2-3 Macros Into Excel
Hello People,
I'm new to this forum and VB actually. I've a piece of Lotus macro code I'd like to convert in VB code. Can any please help? Any suggestions very helpful. I'm learning on the hop here. Code outlined below. Thanks

{HIDE-SHEETS Update info:A1}

The VB equivalent will give me more insight into other lines of code I have.

Thanks once again

Excel 'Enable Macros' Msg -
I have created a programme for others to use but I want to get rid of the Excel message "This programme contains macros. Do you want to enable macros" message that always pops up on opening programme. Or rather I want to always enable macros. Can this be done ? because if the user selects no then programme wont work.

Searching For Excel Macros
Hi all

i want to search one of my drives for all the macros that are on it.
There is no use searching for just .xls files because a lot of the ones returned dont have any embedded macros.I just need all the files that have macros.

Is there anyway to distinguish a if a .xls file has an embedded macros


Excel Macros Revisited
Is it possible to change a recorded Excel macro which contains an Access query to be dynamic?

That is, if I have set the query to only display fields with the autonumber value '3' could I replace this '3' with a variable to let me access different records using the same code?

I would appreciate any help because I really have to get this working soon. Alternative approaches also very welcome.

Starting Macros In Excel
Can someone tell me how to trigger a macro when the user inputs something in a cell? What I want to do is have a macro run whenever the user clicks "Enter" in a specific range of cells (or in any cell for that matter). Is this possible?

Enums In Excel Macros?
Can Enum be used in excel macros? I have put

Private Enum FieldDetails
under the General Declarations of a module in an excel macro. I am getting an error message "Expected Identifier" with Enum highlighted. How can this be resolved?

MS Excel VBA (two Macros Under One Button)
Hello! Is it possible to put two macros under one button. I made a macro to sort my table, but is it possible to make it so that if I press the button it will sort it A to Z and when I press it again it will sort the table from Z to A.

At the moment my code is:

Sub Klass1_AZ()

Selection.Sort Key1:=Range("start1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _

End Sub

It is a standard Macro recording code.

I hope it can be done!


Saveas Excel With No Macros
I need to save an excel worksheet with all macros disabled so no userforms will pop up and it will be smaller when I copy and paste.I hope it makes sense.

excel 2003 vba

Using VB6 To Interface Many Excel Macros
Is it possible to emulate a VBA Form in excel within VB6?

I have serveral macros that I would like to merge together, but I dont want to stick them all in one huge excel file. Is it possible to run a VBA Form within VB6 and have it run macro code when those buttons are clicked?

I'd like to stick all my current macros in a folder, and just list the available macros. When the user clicks on the macro they want, VB6 will "import" that form and all objects will execute their respective code.


Writing Macros For Excel In VB6
Hi All

I am trying to format numbers in excel e.g. having two decimal places, or applying a function to a certain column.

Anyone with any ideas or code examples plz help.

Example of what I mean

Product Selling_Price Cost_Price

Calamari 7899 1422
Venison 1234 1011
Prawns 1563 1112

I want it to look like this after running my function in vb

Product Selling_Price Cost_Price Profit

Calamari 78.99 14.22 64.77
Venison 12.34 10.11 2.23
Prawns 15.63 11.12 11.12

Performance Of Excel Macros Vs. VB 6.0
Hello all,

We have just ported an application from VB macros running under Excel to a native VB 6.0 application. We have experienced a dramatic negative impact on performance. We are implementing a script processing engine which reads a test script from an Excel spreadsheet, parses the cells, and executes the script commands. One feature that illustrates a dramatic decrease in performance is the pre-processing command we implemented to do a sanity check on the script. Using the Excel macros this takes about 2 seconds on a 1000 line script. In the version ported over to VB 6.0 it takes about 2 minutes and 40 seconds. 40 seconds of that is spent just getting the data from the Excel spreadsheet and the other 2 minutes is spent doing string handling.

What in the world is up with that? I would have expected the Excel macros to be slower, as I thought they were interpreted rather than compiled. Can anybody help me with why we've seen such a performance decline?


David Palm
Control Software Engineer
Trane, GCC Control Engineering

How Do I Run Word Macros From Excel With VB?
Can anyone out there help out a VB rookie, please?

I'm trying to code a routine in a MS Excel VB script that will launch a new occurrence of MS Word, open an existing Word document and then run a macro embedded within that document. I can get as far as:

Application.ActivateMicrosoftApp xlMicrosoftWord

...but then can't figure out how to open my document.

Any suggestions welcome.


Microsoft Excel Macros Help!
I need to develop some simple code or macros for microsoft excel workbook that will sort the data for columns A - I when the enter key is pressed at the I column. Or the enter key can be pressed anywhere if not possible at the I column.

Help...exports To Excel.. Macros..???
okay... i have a vb6 form that has a recordset that i want to put into an excel file that has a macro i wrote.. i have gotten it to work by using

open "c:filename.xls" as ouput..

it works well but my problem now is the excel file i want to import the recordset to needs to be able to run a macro.. right now when the recordset is imported it is as a tab delimited file and will not let me have a macro... how can i import the data to excel and use a macro as well...
please help

Copyright 2005-08, All rights reserved