excel-vba

How to increase the textarea of columns through Excel VBA

I'm retrieving data from a table through VBA.The select query gives output correctly.One of the columns that I select has text description which is multiline.So when I get my rows,I want to increase the textaread of my spreadsheet columns dynamically according to the results I'm getting.How can I do this ...

How to create a dynamic button in excel

I'm populating my spreadsheet with Database values.Now if I 30 rows were filled then I want to create a dynamic button on say 31st or 32nd row for doing some action.The number of rows that will be populated is not fixed.How can I do this. ...

Excel VBA: How do you format Charts in Excel with New Data?

Hi, I'm trying to make a macro that formats a chart in Excel 2003 where the data changes. Basically, I have a 20 X values and Y values at all times; however, the values are data specific (I'm making stock price charts that will change depending on the stock I'm analying). I'm trying to make my Y-Axis cross the X axis at the value in ce...

Excel: Adding a Connector Line In a Chart (Have to Use a Macro)?

So I'm working on this chart in Excel, and the chart looks like two sides of a triange, like the picture at the link below: http://a.imageshack.us/img832/6207/triangle.png. I'd like to make a line (like, with an autoshape for example) that connects the 2 endpoints to form a triange; ie a line going from coordinates (4,1) to (4,5). I t...

How do you make a macro in excel not show the selections being made.

I know there's a property to add in the beginning of the macro so that all the selections and deselection happen in the background and are not shown on the sheet. I think I had to disable some property at the beginning of the macro and enable it at the end. Does anyone remember what it was? ...

How to make cells readonly in spreadsheets

I'm populating a spreadsheet with Database values.The cells that I fill data with,I want them to be only read only to the users.How can I do this ...

Calendar in Excel shrinks

Hi, I am using Excel VBA. I added a calendar control so that users can pick the date from the calendar. I noticed something that whenever the excel file is opened the Calendar shrinks smaller and smaller. Now I can see that the calendar will disappear after reopening the file several times. Any ideas? please help Thanks, ...

Excel Macro: error when pasting - moving down 10 rows - pasting - 10 rows - pasting, etc

I'm attempting to copy data from three workbooks (one at a time) from the same range (A4:A8) and paste them into a new workbook. The only catch is I'm trying to make the paste part move down by 10 lines each loop. I'm receiving an error message on the PasteSpecial line. I'm not sure why? (I'm an Excel macro novice, but I'm giving it a ...

Extract Data from Word Document to an Excel SpreadSheet

I have a requirement to extract a value from a word document on a daily basis and write it to an excel workbook. I currently do this manually and it is border line regarding the most efficient method for me Using Excel file create a vba script and add any word document references. 2 Using the word navigate to the table “9. STOCKS......

Combine several Excel files into one using VB

I have a folder with several excel files that have a date field, i.e. 08-24-2010-123320564.xls. I want to be able to have some VB scripting that will simply take the files that start with todays date and merge them into one file. 08-24-2010-123320564.xls 08-24-2010-123440735.xls 08-24-2010-131450342.xls into 08-24-2010.xl...

how to load a sectioned CSV file to an excel sheet?

CSV file: #3GMACRO,,,,,,,,,,,,,, ,,,,,,,,,,,,,, IMSI,IMEI,Date,Time,UMTS MACRO-UARFCNDL,UMTS MACRO-PrimaryScramblingCode,UMTS MACRO-CPICHTxPower,UMTS MACRO-PLMNCellId,UMTS MACRO- RNCId,UMTS MACRO-MCC,UMTS MACRO-MNC,UMTS MACRO - LAC,UMTS MACRO - RAC,UMTS MACRO - MaxUETxPower,UMTS MACRO - MeasuredRSCP 2.6275E+14,3.57539E+14,20100107,16000...

Several Daily Excel Files into one using VB

OK, So Ive got several Excel files that come into a folder each day. For example, Ill have 08-26-2010-1.xls, 08-26-2010-2.xls, etc. Each file has the exact same formatting structure, etc. I need to take those daily files and then stitch them together in a Vb console app. Can someone please help put me into the right direction? Ive found...

Issue while establishing connection with excel

The below connection string establishes connection with excel file which has extension as '.xls' but same string throws an exception while opening a connection with file which has extension as .xlsx. Any idea? ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\abcd\Desktop\demo.xls; Extended Properties=excel 8.0;...

How to delete values of a range in Excel VBA

Hello, I have a range in excel named " ValuesRange" located at Cell "B5". I have four values: 3,4,5,6 located at cells B6,B7,B8,B9 respectively. Given that B10 is always blank. how can delete the four values one by one? Here is the code that I used: Dim startRange as Range Set startRange= Range("ValuesRange").offset.(1,0) while not IsE...

How to return unique value from a range of values Excel VBA

I have a table with three fields (ID, Price, Date) in excel. It has four records as following: ID Price Date 1 $400 1/1/2010 2 $500 1/2/2010 3 $200 1/1/2010 4 $899 1/2/2010 I would like to take each value of the date and place it in a cell A2,A3,A4.... however, I want to take only unique dates and do not take any date tha...

Declaration of an array in Excel VBA

I have in a Excel field (created by someone) a formula containing an Array: =PERCENTILE(Scale1, 0.5). I need to expand this array to other fields. Usually an Array is a range like A1:C52, so expanding it means modifying the formula to, let's say A1:C152. But this "Scale1", even if I can see its border in a blue color, I can't modify i...

How to delete columns of a range Excel VBA

Hello, I have a range named "Start" located at cell "I21". And I have another range named "End" located at cell "Q21". I want to write a code to delete all the columns between them. In other words, I want to delete columns J,K,L,M,N,O,P completely. Here is the code I have: with ThisWorkbook.sheets("Sheet1") 'unprotect sheet .Col...

VBA code works only in the debugging mode and hangs when running in normal mode

Hi, This problem is driving me crazy. I have the following code: 'unprotect sheet If.Range("Start").Row+1<.Range("End").Row then .Rows(.Range("Start").Row+1 & ":" & .Range("End").Row-1).Select Selection.Delete Shift:=xlUp 'protect sheet End if when I run it in debugging mode and trace the code, it works perfectly. But when run t...

Generating reports in Excel VBA and DataGrid

Hi, I have two questions: (1) I am working in Excel VBA project that gets data from stored procedures in SQL SERVER 2005. what is the best way to use reports with Excel VBA? and how to create them? (2) I have used DataGrid with Access before. and wondering if DataGrid control can be found in Excel as well or not? Thanks a lot! ...

How do I write a function that takes a range or list of arguments in Excel VBA?

With SUM for instance, I can do things like: =SUM(F5:F7,F6:F8,A1,E7:G7,F7,2,7) Which takes multiple ranges and/or individual cells and it adds them all up. My question is how do I do this with a VBA function, e.g. to generalize a binary XOR: Function BXOR(A As Integer, B As Integer) As Integer BXOR = CLng(A) Xor CLng(B) End Func...