Search Results

Search found 1188 results on 48 pages for 'vba to c'.

Page 4/48 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • VBA Macro On Timer style to run code every set number of seconds, i.e. 120 seconds

    - by FinancialRadDeveloper
    I have a need to run a piece of code every 120 seconds. I am looking for an easy way to do this in VBA. I know that it would be possible to get the timer value from the Auto_Open event to prevent having to use a magic number, but I can't quite get how to fire off a timer to get something to run every 120 seconds. I don't really want to use an infinite loop with a sleep if I can avoid it. EDIT: Cross-post based on an answer provided is at: http://stackoverflow.com/questions/2341762/excel-vba-application-ontime-i-think-its-a-bad-idea-to-use-this-thoughts-eit

    Read the article

  • VBA Solution to VLOOKUP with Hyperlinks

    - by Emily2
    I am looking for some help with a VBA solution for preserving hyperlinks when using VLOOKUP on Excel (2010). I have a load of data on Sheet 1 for internal use only, and a cut-down version of this on Sheet 2. Instead of recreating Sheet 2 everytime, I am looking to have a working version which updates everytime Sheet1 is updated. Thus, I have used VLOOKUP on Sheet 2 so that only the desired info is returned on sheet 2. However, the problem was that sheet 1 contained in many cells Hyperlinks to external websites, and this would not pull through to Sheet2 using VLOOKUP. With some help, however, using the following VBA solution the hyperlinks now pull through: Function GetHyperLink(r As Range) As String If r.Hyperlinks.Count Then GetHyperLink = r.Hyperlinks(1).Address End If End Function And I am using the following formula in the relevant cell(s) in Sheet2: =HYPERLINK(GetHyperLink(INDEX('Sheet 1'!$B$1:$B$10001,MATCH(A4,'Sheet 1'!$A$1:$A$10001,0))),(VLOOKUP(A4,'Sheet 1'!$A$1:$B$10001,2,FALSE))) However, the problem is with formatting: every cell on Sheet2 is formatted blue and underlined, even although some of them do not contain a hyperlink! Is someone able to help with a VBA solution/formula to fix this last piece of the puzzle? Many thanks, in anticipation.

    Read the article

  • What does the Excel VBA range.Rows property really do?

    - by RBarryYoung
    OK, I am finishing up an add-on project for a legacy Excel-VBA application, and I have once again run up against the conundrum of the mysterious range.Rows(?) and worksheet.Rows properties. Does anyone know what these properties really do and what they are supposed to provide to me? (note: all of this probably applies to the corresponding *.Columns properties also). What I would really like to be able to use it for is to return a range of rows, like this: SET rng = wks.Rows(iStartRow, iEndRow) But I have never been able to get it to do that, even though the Intellisense shows two arguments for it. Instead I have to use one of the two or three other (very kludgy) techniques. The help is very unhelpful (typically so for Office VBA), and googling for "Rows" is not very useful, no matter how many other terms I add to it. The only things that I have been able to use it for are 1) return a single row as a range ( rng.Rows(i) ) and 2) return a count of the rows in a range ( rng.Rows.Count ). Is that it? Is there really nothing else that it's good for? Clarification: I know that it returns a range and that there are other ways to get a range of rows. What I am asking for is specifically what do we get from .Rows() that we do not already get from .Cells() and .Range()? The two things that I know are 1) an easier way to return a range of a single row and 2) a way to count the number of rows in a range. Is there anything else?

    Read the article

  • How do I run some VBA code when a cell is changed?

    - by Gravitas
    I want to add some VBA code when the value in a cell changes. I've already tried Worksheet_Change(), as described at http://www.contextures.com/xlfaqmac.html#WSChange However, this won't work: it only fires when the user changes the value. I want to fire it whenever the value changes, i.e. whenever the spreadsheet recalculates. Any ideas?

    Read the article

  • How to use the autocomplete feature for VBA function in Excel 2007 with Excel Add-In

    - by Nam G. VU
    (cloning from question on SO) I created a function in VBA. I want Excel 2007 to show the Autocomplete when writing this function in the cell's Excel. Detail as How to use the autocomplete feature for VBA function in Excel 2007 with Excel Add-In (.xlam)? ps. In Excel 2010, the autocomplete works In Excel 2007 with Excel Macro-Enabled Worksheet (.xlsm), the autocomplete works. The test file here. But, in Excel 2007 with Excel Add-In (.xlam), the autocomplete NOT works. The test file here.

    Read the article

  • VBA + Polymorphism: Override worksheet functions from 3rd party

    - by phi
    my company makes extensive use of a data provider using a (closed source) VBA plugin. In principal, every query follows follows a certain structure: Fill one cell with a formula, where arguments to the formula specify the query the range of that formula is extended (not an arrray formula!) and cells below/right are filled with data For this to work, however, a user has to have a terminal program installed on the machine, as well as a com-plugin referenced in VBA/Excel. My Problem These Excelsheets are used and extended by multiple users, and not all of them have access to the data provider. While they can open the sheet, it will recalculate and the data will be gone. However, frequent recalculation is required. I would like every user to be able to use the sheets, without executing a very specific set of formulas. Attempts remove the reference on those computers where I do not have terminal access. This generates a NAME error i the cell containing the query (acceptable), but this query overrides parts of the data (not acceptable) If you allow the program to refresh, all data will be gone after a failed query Replace all formulas with the plain-text result in the respective cells (press a button and loop over every cell...). Obviously destroys any refresh-capabilities the querys offer for all subsequent users, so pretty bad, too. A theoretical idea, and I'm not sure how to implement it: Replace the functions offered by the plugin with something that will be called either first (and relay the query through to the original function, if thats available) or instead of the original function (by only deploying the solution on non-terminal machines), which just returns the original value. More specifically, if my query function is used like this: =GETALLDATA(Startdate, Enddate, Stockticker, etc) I would like to transparently swap the function behind the call. Do you see any hope, or am I lost? I appreciate your help. PS: Of course I'm talking about Bloomberg... Some additional points to clarify issues raise by Frank: The formula in the sheets may not be changed. This is mission-critical software, and its way too complex for any sane person to try and touch it. Only excel and VBA may be used (which is the reason for the previous point...) It would be sufficient to prevent execution of these few specific formulas/functions on a specific machine for all excel sheets to come This looks more and more like a problem for stackoverflow ;-)

    Read the article

  • MS Excel Vba/Macro equivalent in LibreCalc or OpenOfficeCalc

    - by ReggieCL
    is there an equivalent macro/vba in libre calc that does this routine; - Read/open xls files in a path and do a batch import/copy of read sheets and merge it with the current open workbook. Here's the vba I used in MS Excel. Thanks in advance Sub Consolidate_Sheets() 'Folder Path to read the xlsx files from Path = "F:\WIP2\Below 25\" filename = Dir(Path & "*.xlsx") Do While filename <> "" Workbooks.Open filename:=Path & filename, ReadOnly:=True For Each sheet In ActiveWorkbook.Sheets 'import/copy sheets from to read xlsx files sheet.Copy After:=ThisWorkbook.Sheets(1) Next sheet Workbooks(filename).Close filename = Dir() Loop End Sub

    Read the article

  • VBA - Instead of ActiveExplorer.Selection to set folder, explicitly set folder path

    - by Mike
    Sub MoveItems() Dim Messages As Selection Dim Msg As MailItem Dim NS As NameSpace Set NS = Application.GetNamespace("MAPI") Set Messages = ActiveExplorer.Selection If Messages.Count = 0 Then Exit Sub End If For Each Msg In Messages Msg.Move NS.Folders("Personal Folders").Folders("SavedMail") Next End Sub This code will move all email messages from the currently selected folder in outlook to another folder (SavedMail). I would like to edit the code so that instead of using the currently selected folder as the source for the messages, there would be a hard-coded folder - something like Set Messages = NS.Folders("Personal Folders").Folders("Moved"). I'm a VBA rookie and tried just replacing the Set Messages line with this which resulted in a Run-time error '13': Type mismatch which I think refers to a mismatch of the Dim Messages and the Set Messages commands. I've tried using different Dim definitions with no luck. I'm guessing that someone who knows VBA will see the way to do this right away. Any help would be greatly appreciated. Thanks.

    Read the article

  • VBA: Parse preceding numbers from string

    - by buttonsrtoys
    I need to parse into two substrings a string that always starts with numeric text followed by alphnumeric text. The strings can vary a bit, but not too much. Below are examples of incoming format and the strings I need: "00 10 50 Information to Bidders" ==> "00 10 50", "Information to Bidders" "001050 Information to Bidders" ==> "001050", "Information to Bidders" "00 10 50 - Information to Bidders" ==> "00 10 50", "Information to Bidders" "001050 -- Information to Bidders" ==> "001050", "Information to Bidders" I was hoping it would only be a half dozen lines of VBA, but my code is turning into a loop where I'm testing every character in the string to see where the changeover from numeric-only to non-numeric, then parsing the string based on the changeover location. Not a big deal, but messier than I was hoping for. Are there VBA functions that would eliminate the need to iterate through each string character?

    Read the article

  • Variable number of arguments in ParamArray ArgList()

    - by Excel VBA guy
    If I want to pass a number of values for the ParamArray arglist via an array, how do I do it? From what I've read so far, on VBA, it appears that I need to explicitly list the values that I want to pass. But what if there are potentially different numbers of values to pass, so I do not know in advance how many I'll want to pass to the function? Is there not some way of using an array (a one-dimensional array) with a variable dimension?

    Read the article

  • Getting around the Max String size in a vba function?

    - by Ommit
    The max number of characters you can use in string in a vba function is 255. I am trying to run this function Var1= 1 Var2= 2 . . . Var256 =256 RunMacros= "'Tims_pet_Robot """ & Var1 & """ , """ & Var2 & """ , """ ... """ & Var256 """ '" Runat=TimeValue("15:00:00") Application.OnTime EarliestTime:=Runat, Procedure:=RunMacros & RunMacros2 ', schedule:=True It runs a procedure at a certain time and passes a bunch of variables to it. but the string is too long.

    Read the article

  • How do you set the "global delimiter" in Excel using VBA?

    - by DanM
    I've noticed that if I use the text-to-columns feature with comma as the delimiter, any comma-delimited data I paste into Excel after that will be automatically split into columns. This makes me think Excel must have some kind of global delimiter. If this is true, how would I set this global delimiter using Excel VBA? Is it possible to do this directly, or do I need to "trick" Excel by doing a text-to-columns on some junk data, then delete the data? My ultimate goal is to be able to paste in a bunch of data from different files using a macro, and have Excel automatically split it into columns according to the delimiter I set.

    Read the article

  • How do you set the "global delimiter" in Excel using VBA (or unicorns)?

    - by DanM
    I've noticed that if I use the text-to-columns feature with comma as the delimiter, any comma-delimited data I paste into Excel after that will be automatically split into columns. This makes me think Excel must have some kind of global delimiter. If this is true, how would I set this global delimiter using Excel VBA? Is it possible to do this directly, or do I need to "trick" Excel by doing a text-to-columns on some junk data, then delete the data? My ultimate goal is to be able to paste in a bunch of data from different files using a macro, and have Excel automatically split it into columns according to the delimiter I set.

    Read the article

  • What is the maximum number of controls that a VBA form can hold?

    - by Lunatik
    I'm currently building an Excel 2003 app that requires a horribly complex form and am worried about limitations on the number of controls. It currently has 154 controls (counted using Me.Controls.Count - this should be accurate, right?) but is probably only about a third complete. The workflow really fits a single form, but I guess I can split it up if I really have to. I see evidence in a Google search that VB6 (this usually includes VBA) has a hard limit of 254 controls in a form. However, I created a dummy form with well over 1200 controls which still loaded and appeared to work just fine. I did get some 'out of memory' errors when trying to add specific combinations of controls though, say 800 buttons and 150 labels, leading me to think that any limit might be affected by the memory requirements of each type of control. Does anyone have any information that might help ensure that I or, more importantly, other users with differing environments don't run into any memory issues with such a large form?

    Read the article

  • How to Create VBA Add-In with Shared Codes for All Excels?

    - by StanFish
    I'm writing VBA codes for multiple Excel spreadsheets, which will be shared with others from time to time. At some point I find there are lots of duplications in my works. So I want to find a way to share codes in a sort of Excel add-in, like the .xla file. But when I tried to save the Excel file containing shared codes as .xla file, I got some problems: The file cannot be edit anymore after I save it in the default add-in folder If I move the .xls file to a folder other than the add-in folder, and open it directly - I cannot use its classes - which creates problems for sharing the codes Any ideas to create add-ins in a flexible and powerful way please? Thanks a lot for the help

    Read the article

  • How to change the range of a chart in Excel using VBA?

    - by Pieter
    Hi guys, I'm using an Excel sheet to keep track of a particular time series (my daily weight, if you must know). I created a macro that inserts a row, automatically adds today's date and calculates a moving average based on my input. There is also a chart to visualize my progress. I have tried recording a macro that updates the time series in the graph, but to no success. How can I create a macro or VBA script that, when executed, updates the range of the graph from A(x):Cy to A(x-1):Cy to include today's measurement? Thanks!

    Read the article

  • Defining multiple VBA objects within one function or sub-routine?

    - by Harokitty
    I have the following VBA code: Option Explicit Private a(2) as Double Private b(2) as Double Public Function Hello(X1 As Double, X2 As Double) As Double a(1) = X1 + X2 a(2) = X1/X2 b(1) = X1 b(2) = X2^2 Hello = a(1)+a(2)+b(1)+b(2) End Function Within the function Hello I have defined a(1),a(2),b(1),b(2). However, I want to make some function or sub-routine that accepts X1 and X2 as arguments and spits out the values for a(1),a(2),b(1),b(2). This is because I use the above definitions for a(1),a(2),b(1),b(2) in about 20 functions in my module and would like to avoid having to do the following in each function that I use thesis in: a(1) = X1 + X2 a(2) = X1/X2 b(1) = X1 b(2) = X2^2

    Read the article

  • How can i pass nothing or a blank cell to an Optional argument in VBA?

    - by user2985990
    I am trying to set up a function so that whether I pass a blank cell or do not even select a cell for the argument it returns the function I am looking for. Here is my code: Function FinancialsAge(FirstBirthday As Date, BeginningDate As Date, Optional Second Birthday As Variant) As String If IsMissing(SecondBirthday) = True Or SecondBirthday = vbNullString Then FinancialsAge = Year(BeginningDate - FirstBirthday) - 1900 ElseIf SecondBirthday Then FinancialsAge = (Year(BeginningDate - FirstBirthday) - 1900) & "/" & (Year(BeginningDate - SecondBirthday) - 1900) End If End Function This code works fine as long as I select a blank cell for the third argument but when I leave the third argument out I get a "#Value!" error in the cell. Anyway to do this in Excel VBA so that the function works under both circumstances? Thanks,

    Read the article

  • VBA to C# - Porting Userforms to Winforms?

    - by John M
    I am porting a Excel-VBA based app which uses Userforms over to a C# Winforms application. How do I convert the Height and Width of the VBA-Userform to the same screen dimensions in the C#-Winforms application? Is there a ratio that can use be used? Currently the VBA-Userform has a dimension of 179.25 W x 245.25 H which is optimized for use on a quarter-VGA device.

    Read the article

  • VBA: Read file from clipboard

    - by ReturningTarzan
    I'm trying to load a file in a VBA macro that has been copied from, say, an Explorer window. I can easily get the data from the clipboard using DataObject::GetFromClipboard, but the VBA interface to DataObject doesn't seem to have methods for working with any other formats than plain text. There are only GetText and SetText methods. If I can't get a file stream directly from the DataObject, the filename(s) would also do, so maybe GetText could be forced to return the name of a file placed on the clipboard? There is very little documentation to be found for VBA anywhere. :( Maybe someone could point me to an API wrapper class for VBA that has this sort of functionality?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >