excel-vba

Userform wont work with Zero Balance in txtBox

I Have a problem with this VBA Code; It works fine when the Debtor Currently has an outstanding Balance, but when their Balance is "" it throws an error and Highlights; Balance = CSng(txtBalance.Value) Any help would be appreciated, I assume it would require something like; If txtBalance.Value = "" Then Worksheets("De...

excel vba get range of user selected range by mouse

Hi All, this is not the usedrange issue. For example in excel user selects a range (possibly empty) using mouse, let's say B4:C12. And let's say after this without deselecting the range user presses the macro, and macro should tell B4:C12. Can anyone show example? Thanks a lot in advance! the macro should be smth along the lines of the ...

ActiveX controls move when pushing XML data into Excel Table

I am pushing XML data into an Excel Table via C#, but when I do this, my ActiveX checkboxes lower on the page do not adjust their position. The spreadsheet rows move down, but the checkboxes do not. Also, at times it seems like even though the cells on the spreadsheet shift down, the row heights do not, messing up the formatting. I t...

How to protect excel workbook using VBA?

with a trigger like a check box i want to protect my work book i tried excel 2003 thisworkbook.protect("password",true,true) thisworkbook.unprotect("password") its not working.. any suggestions ...

How to wrap comment.text in vba

I have a situation in which text in one of the cells is massive.When I change the contents of this cell the previous value becomes a comment to that cell.Now the problem is, this text is so big that I cannot see complete text.If I use .Shape.Textframe.Autosize=true then I have to go on browsing till god knows when to see the text. What ...

connecting to access data base and write to table

I have an excel invoice sheet and I want to write the information from the invoice to a table in an Access file. My following code is: Private Sub Button66_Click() Dim con As New ADODB.Connection Dim connectionString As String Dim sql As String connectionString = "DBQ=c:\Users\Public\Public Desktop\InvoiceRecords.mdb; Driver={Microsof...

Inserting a foreign key. Excel VBA and MS Access 2003

Hi, I have two tables: Department(Dept_ID,Dept_Name). and table Employee(Empl_ID, Empl_Name,Salary,Dept_ID). The IDs are auto-numbers. Dept_ID in table Employee is a foreign key refering to Dept_ID in Table Department. Now, I want to insert a record to table Employee using Excel VBA which is connected to Access 2003 database where my ta...

VBA error when executing a sybase stored procedure

Hello, I have the following code that executes a Stored Procedure in Sybase throught VBA. Sub GetInfo() Dim rstRUB As ADODB.Recordset Dim strRUB As String Dim strcnn As String Dim productType As String Dim DealId As String strcnn = "DSN=KONDOR_QUA;DATABASE=Kustom;UID=odbcuser;PWD=odbcuser123;" Set cnn = Ne...

How to consolidate data by domain in excel?

I have a spreadhseet that looks something like this: Referrer --- Clicks --- Conversions http://google.com/search?q=hello+world ---- 12 ---- 3 http://george.com ---- 4 ---- 1 http://google.com/search?q=yeah ----- 3 ---- 3 http://george.com/2010/3/this-blog ----- 4 ---- 0 http://www.wave-runner.com/hey ---- 3 ---- 0 How can I write a m...

Hiding Rows Based on Information in Two Different Columns

Hi, I need to be able to hide a row if the numbers in column "c" and in column "d" are zero. I the below code works but stops after looping through only 4 rows of data. There is nothing different between the data so I don't know why it stops. Can someone please help me? Thank you. Sub Hide_Row_3() ' Hide_Row_3 Macro Worksheets("Costs...

how do I force a screen update in Excel VBA?

My Excel tool performs a long task, and I'm trying to be kind to the user by providing a progress report in the status bar, or in some cell in the sheet, as shown below. But the screen doesn't refresh, or stops refreshing at some point (e.g. 33%). The task eventually completes but the progress bar is useless. What can I do to force a sc...

Excel VBA: automating copying ranges from different workbooks into one final destination sheet?

I'm going to be generating some graphs from a lot of data located in multiple workbooks. The data is formatted exactly the same in all workbooks and reside in folders all at the same level. I'm going to be bringing parts (ranges) of the data into one final workbook where I'll generate my graphs from. This made me think that this sort of...

Excel VBA - Create Multiple Columns on Sheet2 from 1 column on Sheet1 with logic

I am new to VBA and i am struggling trying to make this work. I am in need of a macro that will process each cell\Column on Sheet1 and Put the Results on Sheet2. I'm sure this is pretty easy for those who are more advanced with VB code. It contains many columns.. Anytime we encounter a "—" or an empty cell we populate the cell with -999...

Excel: How to set list data validation to point to a column in a named range

I have a named range called "items" spanning 3 cols and 10 rows. In another worksheet I have a cell that uses a data validation list to allow a user to select from a drop down. In the source I want to specify the first column of the named "item" range. Is this possible? ...

How to get Shape's internal name in Excel

When a picture is inserted into an Excel worksheet using Shapes.AddPicture(...) method, Excel gives it a name "Picture 1", "Picture 2" etc automatically. This name can be used to get a reference to this shape object in Shapes collection like Shapes.Item("Picture 1"). If the name is changed in Excel using the Name Box, there are two diff...

Excel macro to copy a row from one sheet to another based on time hourly criteria.

I'm pulling a list of data from a system via web query into a blank worksheet in Excel, and then I want to copy the rows for a particular time to a particular worksheet (e.g., all Monday data from System worksheet to the Delay worksheet, all Tuesday data from Sistem worksheet to Tues worksheet, etc.). Sample data - System worksheet Ca...

Updating a table Access and Excel VBA

Hi, I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed in an excel sheet that is connected with MS Access database. ID is the only unique field. Sometimes, my user submits a transaction that has let's say 5 records. Then, they want to modify the submitted data in case if they en...

How to Rename a series or range names and make their scope global

• I have 2 template sheets (in Excell 2010) called “DefaultDesign” and “DefaultDesignMaterials” with a number of cell names with a workbook scope. For Example, a range name is called “DefaultDesign_NumberOfServers” with workgroup scope. I want to copy these 2 template sheets and rename them to “Design1” and “Design1Materials”, and the...

VBA/Excel - Out of Memory

Hi all, I'm coding a Macro in VBA for Excel 2007 (file type .xlsm) My Macro runs very well for the first time. But, at the second run, when i give the variable (an array of thousand items) a new value, the VBA says "Out of Memory". I tried with different commands: Set Obj = nothing , Erase variable, variable = empty but it didn't wor...

Excel 2003 Workbook Form Controls sometimes resize when viewed through a Virtual Machine

I develop for clients who are still using Excel 2003 on Windows XP systems. Therefore we develop within a Virtual Machine running XP and Office 2003. I often create menu or control sheets within files using Form Control objects, mainly button controls. Sometimes when I open these workbooks up, the controls resize themselves (bigger, sma...