Search Results

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

Page 24/48 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Loop a formula in excel VBA

    - by CEMG
    I am trying to loop a formula in Column "D" until Column "B" doesn't have any more data. The formula I am adding to Column "D" is : IF(ISNUMBER(C5),C5,IF(C5A5/3+OFFSET(C5,-1,0)) ,IF(C5<C6,((OFFSET(C5,1,0)-OFFSET(C5,-2,0))(A5/3)+OFFSET(C5,-2,0)),""))) So the result I want in Column "D" once the macro is run is this: A B C D 3 May-10 78.0000 78.00000 1 Jun-10 52.06667 2 Jul-10 26.13333 3 Aug-10 0.2000 0.20000 1 Sep-10 0.21393 2 Oct-10 0.22786 3 Nov-10 0.2418 0.24179 1 Dec-10 0.26640 2 Jan-11 0.29102 3 Feb-11 0.3156 0.31563 1 Mar-11 0.34821 2 Apr-11 0.38080 3 May-11 0.4134 0.41338 1 Jun-11 0.44992 2 Jul-11 0.48646 3 Aug-11 0.5230 0.52300 1 Sep-11 0.56440 2 Oct-11 0.60580 3 Nov-11 0.6472 0.64720 1 Dec-11 0.43147 If someone can help me at what I am doing wrong with the VBA codes I would greatly appreciated. My CODES are the following: Sub IsNumeric() // first logic: IF(ISNUMBER(C6),C6 // If Application.IsNumber(Range("c5").Value) Then Range("d5").Value = Range("C5").Value // second logic: IF(C6 ElseIf Range("c6").Value < Range("c5").Value Then Range("d6").Value = Range("c6").Offset(2, 0).Value - Range("c6").Offset(-1, 0).Value * (Range("a6").Value / 3) + Range("c6").Offset(-1, 0).Value // third logic: IF(C6<C7,((OFFSET(C6,1,0)-OFFSET(C6,-2,0))*(A6/3)+OFFSET(C6,-2,0)),""))) // ElseIf Range("c6").Value < Range("c7").Value Then Range("d6").Value = (Range("c6").Offset(1, 0).Select) - Range("c6").Offset(-2, 0).Select * (Range("a6").Select / 3) + Range("c6").Offset(-2, 0).Select Else Range("d6").Value = "" End If End Sub

    Read the article

  • Requested operation requires an OLE DB Session object... - Connecting Excel to SQL server via ADO

    - by Frank V
    I'm attempting to take Excel 2003 and connect it to SQL Server 2000 to run a few dynamicly generated SQL Queries which ultimately filling certain cells. I'm attempting to do this via VBA via ADO (I've tried 2.8 to 2.0) but I'm getting an error while setting the ActiveConnection variable which is inside the ADODB.Connection object. I need to resolve this pretty quick... Requested operation requires an OLE DB Session object, which is not supported by the current provider. I'm honestly not sure what this error means and right now I don't care. How can get this connection to succeed so that I can run my queries? Here is my VB code: Dim SQL As String, RetValue As String SQL = " select top 1 DateTimeValue from SrcTable where x='value' " 'Not the real SQL RetValue = "" Dim RS As ADODB.Recordset Dim Con As New ADODB.Connection Dim Cmd As New ADODB.Command Con.ConnectionString = "Provider=sqloledb;DRIVER=SQL Server;Data Source=Server\Instance;Initial Catalog=MyDB_DC;User Id=<UserName>;Password=<Password>;" Con.CommandTimeout = (60 * 30) Set Cmd.ActiveConnection = Con ''Error occurs here. ' I'm not sure if the rest is right. I've just coded it. Can't get past the line above. Cmd.CommandText = SQL Cmd.CommandType = adCmdText Con.Open Set RS = Cmd.Execute() If Not RS.EOF Then RetValue = RS(0).Value Debug.Print "RetValue is: " & RetValue End If Con.Close I imagine something is wrong with the connection string but I've tried over a dozen variations. Now I'm just shooting in the dark.... Note/Update: To make matters more confusing, if I Google for the error quote above, I get a lot of hits back but nothing seems relevant or I'm not sure what information is relevant.... I've got the VBA code in "Sheet1" under "Microsoft Excel Objects." I've done this before but usually put things in a module. Could this make a difference?

    Read the article

  • problem linking vba modules in MS Access 2007

    - by Ted
    I am upgrading a database system from Access 2000 db to Access 2007, which communicates with several chemistry measuring devices(pH meter, scale, etc) via an RS 232 serial port. The first db consists of several modules containing vba code that enables the communications with the ports, as well as supports the code behind the forms in the second db. The user, or lab tech, navigates through the forms in the second db to interact with the lab devices, and also to generate the reports which display the info. from the devices. The reports are also part of the second db. The code works in Access 2000, but once I convert it to 2007, the code in the second db cannot find the function calls in the first db that dictate the progression from screen to screen. I have tried importing the modules into the second db, and I have tried linking them, but it still doesn't work. The error message is #438: "Object doesn't support this property or method." Any suggestions would be greatly appreciated. Here is the code for the first function that is not being called correctly: Description: ' This routine is used to return to the calling form and close the active form. ' ' Input: ' strFormCalled --- the active form ' strCallingForm --- the form that called the active form ' blnUnhideOrOpen --- whether to open or just unhide form Public Sub basReturnToCallingForm(ByVal strFormCalled As String, ByVal _ strCallingForm As Variant, Optional blnUnhideOrOpen As Boolean = True) On Error GoTo err_basReturnToCaliingForm If Not basIsBlankString(strCallingForm) And blnUnhideOrOpen Then DoCmd.OpenForm strCallingForm, acNormal Else Call basUnHideForm(strCallingForm) End If Call basCloseForm(strFormCalled) exit_basReturnToCaliingForm: Exit Sub err_basReturnToCaliingForm: Err.Raise Err.Number, "basReturnToCaliingForm", Err.Description End Sub I will post the second function shortly, but I have to go to a meeting... The second funtion that isn't 'working' is a cmdStartClick that is supposed to be called when a user initializes a pump. However, within that function, it's also sticking on a line that is supposed to progress to the next form in the db. The other thing is that the code works in Access 2002, but not in Access 2007...

    Read the article

  • Why is Excel's 'Evaluate' method a general expression evaluator?

    - by jtolle
    A few questions have come up recently involving the Application.Evaluate method callable from Excel VBA. The old XLM macro language also exposes an EVALUATE() function. Both can be quite useful. Does anyone know why the evaluator that is exposed can handle general expressions, though? My own hunch is that Excel needed to give people a way to get ranges from string addresses, and to get the value of named formulas, and just opening a portal to the expression evaluator was the easiest way. (The help for the VBA version does say its purpose it to "convert a Microsoft Excel name to an object or a value".) But of course you don't need the ability to evaluate arbitrary expressions just to do that. (That is, Excel could provide a Name.Evaluate method or something instead.) Application.Evaluate seems kind of...unfinished. It's full behavior isn't very well documented, and there are quite a few quirks and limitations (as described by Charles Williams here: http://www.decisionmodels.com/calcsecretsh.htm) with what is exposed. I suppose the answer could be simply "why not expose it?", but I'd be interested to know what design decisions led to this feature taking the form that it does. Failing that, I'd be interested to hear other hunches.

    Read the article

  • SQL - Query range between two dates (NON-VBA)

    - by Mohgeroth
    I see various topics on this around stack overflow but none that fit the contect of MS-Access... Given a starting date and an ending date, is there a way through SQL to return records for each given month within the time frame? EG: Between #1/1/2010# and #12/31/2010# results #1/4/2010# #1/11/2010# ..... #12/27/2010# Restrictions MS-Access 2003 :No Case/Loops inside the SQL (IIF statements are good) This is a view only, NO VBA will be used since the data will not be tampered with. Disconnected recordset is my last option. I would prefer to find out theres some way to call your customized functions in the SQL to help return these values... some class stored on a global scope while you iterate through this date range maybe... Is this possible? I see many no's, but if there was a way to pass a value into a function I could find a way to make this work. Sad that I don't have a way to simulate a stored procedure without using a d/c recordset, at least that I know of... any experts out there know a way?

    Read the article

  • Set the background color for a fixed range of cells

    - by Count Boxer
    I have VBA code in an Excel spreadsheet. It is used to set the font and background color of a cell based on the value in that cell. I am doing it in VBA instead of "Conditional Formatting" because I have more than 3 conditions. The code is: Private Sub Worksheet_Change(ByVal Target As Range) Dim c As Range, d As Range, fc As Long, bc As Long, bf As Boolean Set d = Intersect(Range("A:K"), Target) If d Is Nothing Then Exit Sub For Each c In d If c >= Date And c <= Date + 5 Then fc = 2: fb = True: bc = 3 Else Select Case c Case "ABC" fc = 2: fb = True: bc = 5 Case 1, 3, 5, 7 fc = 2: fb = True: bc = 1 Case "D", "E", "F" fc = 2: fb = True: bc = 10 Case "1/1/2009" fc = 2: fb = True: bc = 45 Case "Long string" fc = 3: fb = True: bc = 1 Case Else fc = 1: fb = False: bc = xlNone End Select End If c.Font.ColorIndex = fc c.Font.Bold = fb c.Interior.ColorIndex = bc c.Range("A1:D1").Interior.ColorIndex = bc Next End Sub The problem is in the "c.Range" line. It always uses the current cell as "A" and then goes four cells to the right. I want it to start in the "real" cell "A" of the current row and go to the "real" cell "D" of the current row. Basically, I want a fixed range and not a dynamic one.

    Read the article

  • COM Interop without regasm

    - by SLaks
    I'm a limited user, and I need to write an Outlook macro that exposes a C# library in Outlook 2003 and 2007. I do not have any admin privilges at all, not even at install time, so I can't run RegAsm and I can't (I assume) write a managed add-in. Is there any way to call .Net code from VBA in this scenario, or are there any other solutions? This is for personal use only, so an ugly hack is perfectly acceptable (so long as it works)

    Read the article

  • ArcObjects - enumerating feature classes and datasets within a geodatabase

    - by Tom
    I'm trying to enumerate the contents (feature classes and feature datasets, not interested in tables, etc) of a file geodatabase using vba/arcobjects. I have the file GDB set as an IGxDatabase object, but can't find a way of getting further in. I've had a look at the geodatabase object model and tried using IFeatureClass and IFeatureDataset but neither seem to return useful results. Thanks in advance for any assistance

    Read the article

  • Can I have a macro in Visual Studio 2005 call a DOS command and redirect the output to a file?

    - by Mark
    I'd like to have a macro in Visual Studio 2005 that calls a DOS command and redirects the output (stdout and stderr) to a file. Just calling the command and "" redirecting it will not capture stderr, so there are two parts to this: calling a DOS command capturing both stderr and stdout to a file during that call I'd then like to open this file in Visual Studio after the command completes. I'm new to Visual Studio 2005 macro writing, and VB/VBA, so that's the kind of help that I'm looking for. Thanks, Mark

    Read the article

  • Formula to follow addition of rows

    - by Wayne McCaslin
    New to VBA, please help. I have a range say A2:D10; input causes rows to be added. New entries are being added using NextRow=_. Works perfectly, however, how do I get the formulas in columns C and D to follow each new row being added. I cannot just format entire column due to my sort criteria. Example formula is =IF(ISTEXT($B11),$C$2-$D11,"")

    Read the article

  • MS Access 2007 - Property for text box to allow end-user to hit enter for return, not next

    - by Justin
    So I have a form that user's use for data entry, and on one form there is a text box there that is basically used. To enter notes. However, if the user hits i need the cursor to stay in that text box, and start a new line (uh....like word would)....but currently it is jumping to the next control (text box). So is there a simple property setting that would do the trick? Or a VBA method to accomplish? Thanks Justin

    Read the article

  • Sort Outlook Inbox "Arrange By" | Switch between FROM and Conversation View

    - by DarkSprout
    Using VBA and a toolbar button, I'd like to be able to Switch between FROM and Conversation View, but I just work how to or find any code to do this. I tried the Sort Methods but, they only work in memory and don't re-sort the actual inbox. I use Conversation View for GMail style functionality with my Sent items BCC'd to myself, but want to switch to 'From' with all Groups Collapsed - so that I can find emails from certain people quickly. Any Ideas? With Thanks =|)arkSprout=

    Read the article

  • Outline to teach VB6

    - by sinDizzy
    I am in need of an outline on teaching VB6/VBA to some co-workers. The material I am pretty confident I can fill in, just need a sense of how to order the class material. Its not going to be hard core programming [nix the VB6 jokes please :) ] but do want to touch the basics. Any free outlines or even entire presentations out there that I can use? I've been looking but nothing concrete so far. thanks

    Read the article

  • Date Difference, Excluding certain Times and Dates

    - by Josefvz
    Hi Folks. I'm looking for a way to determine the difference between two dates. A normal SQL DATEDIFF statement won't cut it because I need to excluded non working Hours and days Namely Weekends and any time between 16:00 - 7:00. Something similar to the NETWORKDAYS function in excel. I'm codeing an excel spreadsheet. Using VBA connect to a SQL server to pull data.

    Read the article

  • Finding The DSN To My Database?

    - by Soo
    I have an SQL database and want to connect to it using VBA in order to support some legacy functionality. I'm using an ADODB connection and need to know what my database DSN is. How can I find this? I'm using SQL Server 2008, thanks! :D

    Read the article

  • sending AT COMMANDS

    - by I__
    does anyone know where i can get the official list of all AT COMMANDS available? i would like to get my computer speaking to my cell phone. i need all AT COMMANDS and i will hook it up to either .NET or VBA or anything else.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >