excel-vba

Excel VBA "Autofill Method of Range Class Failed"

The following VBA code (Excel 2007) is failing with Error 1004, "Autofill Method of Range Class Failed.". Can anyone tell me how to fix it? Dim src As Range, out As Range, wks As Worksheet Set wks = Me Set out = wks.Range("B:U") Set src = wks.Range("A6") src.AutoFill Destination:=out (note: I have Googled, etc. for this. It comes u...

response.ContentType="application/vnd.ms-excel" resizing spreadsheet columns width

Hi, Opening an excel spreadsheet with the response object and I am curious to know if there is a way, once all the data has been written to resize/format the columns widths so that all the data fits? Thanks, Ron. ...

Lock Excel Document after a certain Date

How can I cripple an excel document after a certain date? I want it to become unusable after, say, 12/31/2009. I was thinking about putting one of those Must Enable Macros things in there that hides all the sheets on close and leaves one tab that says you must enable macros. Then having an on open macro that unhides all those tabs, bu...

How to pause for specific amount of time?

I have an Excel worksheet that has the following macro. I'd like to loop it every second but danged if I can find the function to do that. Isn't it possible? Sub Macro1() ' ' Macro1 Macro ' Do Calculate 'Here I want to wait for one second Loop End Sub Thanks. ...

Has the way excel evaluates the Date type changed in Excel 2007

I have some fairly old code that runs just fine in Excel versions before 2007. In 2007, it throws a runtime error: run-time error 16 : expression is too complex. The expression is pretty simple and the error seems unrelated to the actual problem. I'm trying to compare 2 dates. Example code follows: Function getContractEnd() As Date ...

Counting rows by the different date

I have a column of dates and a column of items. Hi Everyone I want to count the number of items for a certain date, how many of them are per day. Column 1 Date - Column 2 - Items 01.09.2009 IT004   01.09.2009 IT004 01.09.2009 IT005 01.09.2009 IT006 01.09.2009 IT006 01.09.2009 IT006 06.09.2009 IT004 06.09.2009 IT004 06.09.2009 I...

Array from Range in Excel VBA

Well I've been struggling with the little bit of code and can't seem to get around it ... I'm trying to get an array from a range of cells, the array however is showing up to be 1 element wide. Well here's the code: Dim item As Variant MsgBox Range("D19:H19").Count item = Range("D19:H19").Value MsgBox LBound(item) & " " & UBound(i...

Excel macro doesn't update correctly

Hi i have created macro for excel but it seems somewhere i have done something wrong, i want to fetch an image from a URL and then update it up to 1 second (more or less) Sub GetPicture() PictureURL = "This is where i put the URLi want" Set MyPict = ActiveSheet.Pictures.Insert(PictureURL) Cells(1).Value = Now nextTime = Now + TimeV...

Visual Basic (for Applications) Learning Resources

As resident techie I have been charged with teaching some colleagues VB specifically for use with Excel. My main duties involve MySQL and Objective-C and haven't touched VB since University. While I'm not worried about the prospect of learning VB (how hard can it be, right?). I have no clue on where to point my "students" to start. Any...

Using a formula from another column in Excel

I'll simplify this for example sake I have a formula in column B which is Ax + 2, e.g. in B1, it's A1 + 2 in B2, it's A2 + 2 I want to make a formula in column Y which mirrors whatever formula is in column B at all times but replaces the A in the formula with a X. e.g. in Y1, it's X1 + 2 in Y2, it's X2 + 2 No matter what...

How to fall through a Select Case in Excel VBA?

Given Select Case cmd case "ONE": MsgBox "one" case "TWO": MsgBox "two" case "THREE": MsgBox "three" End select My requirement is if cmd = "ONE" I need "one" and then "two" displayed however currently I am getting "one" displayed and then the program is breaking out of the select case... ...

How do I select the top third and bottom third items in excel

Hi, how do I select the top third and bottom third items from a list in excel ...

append a text string to the left of all the cells of a column in excel 2002?

Hello ! I have two columns with two values.. I want to append some text to the left of all the cells of Column A and concatenate to the right of all the cells of Column B. Basically I'm trying to avoid having to type in a whole bunch of sql updates. so for example if i have an excel with ID Employee Name 135 Rasputin 76 Bush I wan...

How to insert data from an excel sheet into a database table??

Hi, I need to insert the data from an excel sheet into a teradata table. and I need this to be done using a MACRO. I have data in an excel sheet like COL1 COL2 COL3 COL4 1 2 3 4 2 5 8 10 . . so on and i need to keep a button in the excel sheet and assign a macro to that button so that when i click the button...

Can this be done using excel macos?

Hi Guys, I am new here and have been refered to this site by someone who thinks its the best site for programmers. I also think it is!! I am new to Vb and excel Macros. I want to do the following things with a 13 column and 1000 rows spreadsheet. Determine the Unique items on Column A to J Move the Unique items to a new Sheet Transp...

VBA: Querying Access with Excel. Why so slow?

I found this code online to query Access and input the data into excel (2003), but it is much slower than it should be: Sub DataPull(SQLQuery, CellPaste) Dim Con As New ADODB.Connection Dim RST As New ADODB.Recordset Dim DBlocation As String, DBName As String Dim ContractingQuery As String If SQLQuery = "" Then Else DBName = Range...

How to create excel add-in (excel 2003 or previous version) package with activeX dll?

Hi, guys, I am new to excel add-in prgramming and I am having a existing excel add-in project need to modify. The plug-in has 2 parts, one is programmed in VB and compiled into a ActiveX DLL file, the other part is inside the excel as an add-in. I already modified the source code of the DLL and recompiled a new DLL, but I don't know w...

Methods in EXCEL Addin - XLL

Hi, How do I know which methods are available in my XLL module, in case i need to use / call any of them in my VBA code. I can do this by calling the: Application.Run() method, in which I have to pass my macro-name as the parameter. My question is about this macro-name: how do I know which macros are present in my XLL addin. Any h...

Using VBA to change Excel data

Hi all, I have some Excel data that looks like the following (top two rows): and I need to get it looking like the data on the bottom rows. I've not really used Excel VBA before, so can someone point me in the right direction of where to start with this please? Many thanks in advance leddy ...

How to determine if a date falls on the weekend (Excel VBA)

Given a date as input, how can I determine whether the day falls on a weekend? ...