Search Results

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

Page 37/48 | < Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >

  • Summary statistics in visual basic

    - by ben
    Below I am trying to write a script the goal of which is to calculate some summary statistics for a few different columns of numbers. I have gotten some help on it up to the "Need help below" mark. But beyond that I am flabergasted as to how to calculate the simple stats (sum, mean, standard deviation, coefficient of variation). I know VB has scripts for these stats, which I have included in my code, but I guess I need to do some extra declaring or something. Advice much appreciated. Thanks. Sub TOAinput() Const n As Integer = 648 Dim stratum(n), hybrid(n), acres(n), hhsz(n), offinc(n) Dim s1 As Integer Dim s2 As Integer Dim i As Integer For i = 1 To n stratum(i) = Worksheets("hhid level").Cells(i + 1, 2).Value Next i s1 = 0 s2 = 0 For i = 1 To n If stratum(i) = 1 Then s1 = s1 + 1 Else: s2 = s2 + 1 End If Next i Dim acres1(), hhsz1(), offinc1(), acres2(), hhsz2(), offinc2() ReDim acres1(s1), hhsz1(s1), offinc1(s1), acres2(s2), hhsz2(s2), offinc2(s2) 'data infiles: acres, hh size, off-farm income, For i = 1 To n acres(i) = Worksheets("hhid level").Cells(i + 1, 4).Value hhsz(i) = Worksheets("hhid level").Cells(i + 1, 5).Value offinc(i) = Worksheets("hhid level").Cells(i + 1, 6).Value Next i s1 = 0 s2 = 0 For i = 1 To n If stratum(i) = 1 Then s1 = s1 + 1 acres1(s1) = acres(i) hhsz1(s1) = hhsz(i) offinc1(s1) = offinc(i) Else: s2 = s2 + 1 acres2(s2) = acres(i) hhsz2(s2) = hhsz(i) offinc2(s2) = offinc(i) End If Next i '**************************** 'Need help below '**************************** Dim sumac1, sumac2, mhhsz1, mhhsz2, cvhhsz1, cvhhsz2 sumac1 = Sum(acres1) sumac2 = Sum(acres2) mhhsz1 = Average(hhsz1) mhhsz2 = Average(hhsz2) cvhhsz1 = StDev(hhsz1) / Average(hhsz1) cvhhsz2 = StDev(hhsz2) / Average(hhsz2) End Sub

    Read the article

  • Excel macro to change location of .cub files used by pivot tables? (to allow .xls files that depend

    - by Rory
    I often use Excel with pivot tables based on .cub files for OLAP-type analysis. This is great except when you want to move the xls and you realise internally it's got a non-relative reference to the location of the .cub file. How can we cope with this - ie make it convenient to move around xls files that depend on .cub files? The best answer I could come up with is writing a macro that updates the pivot tables' reference to the .cub file location....so I'll pop that in an answer.

    Read the article

  • PRINTER SET UP IN EXCEL VISUAL BASIC

    - by Gina
    I am trying to assign a cell in excel for the user to type the printer name where they want the print out to go and then use that value in the Application.ActivePrinter = (use the cell value) Even though I have done the programming assigning a name to the cell and using it in a variable it is giving me an error. I have set my variable as string, text, object and variant already and it's not working. Do you know what code should I use to be able to do this?

    Read the article

  • Access startup form locked GUI

    - by Brad
    I just had an interesting experience with a startup form in MS Access 2010. I designed a login form and when I thought I was done I set my startup form to be the login form I'd just created. I then closed Access and reopened it but my login form did not appear. Instead the whole GUI was locked. I cannot click on anything. My form was working during my tests before I set it as a startup form and reloaded Access. How can I either remove my form as a startup object or get the use of my GUI back?

    Read the article

  • Form wont stay on top. How do I keep my excel form from hiding behind other windows after I browse

    - by ScottK
    I have a vb.net program that opens up an excel workbook and runs a macro ("Report") in that workbook when a button is clicked. //Workbook with macro and form xlWorkbook = xlApp.Workbooks.Open("W:Data\Excel Program.xls") //Macro: xlApp.Run("Report") //Macro opens form from workbook. I browse for my two .csv files //and then click a button to run code that creates my reports. //form closes, show the excel report after its created xlApp.Visible = True After I browse my first file and select it so that its location is displayed in my text box, the excel form then hides behind any open windows. I want this form to stay on top. It is after this code executes that the form will hide behind all other open windows: Private Sub btnBrowseFile1_Click() Dim fileName1 As String fileName1 = Application.GetOpenFilename("CSV file (*.csv), *.csv") If fileName1 <> "False" Then Me.txtFileName1.text = fileName1 End If End Sub EDIT: I still have no luck with this problem. When the excel macro is opened from a vb program I have this hiding issue...but only after browsing for a file. Why does the focus leave the form and go to Windows after browsing a file? Any one have any suggestions?

    Read the article

  • excel quotes in formula question

    - by I__
    i have a column with this data: IT_AMPH IT_BARB IT_BENZ IT_BUP SOMA i want the column next to it to be literarely =like "*,IT_AMPH,*" =like "*,IT_BARB,*" =like "*,IT_BENZ,*" etc please note that i want the equal signed to be displayed, exactly as shown above what would be the formula for this?

    Read the article

  • How do I repeat function over several row.

    - by ChrisBD
    I'll admit that I'm not an Excel guru so maybe someone here can help me. On my worksheet I have several blocks of data. I calculate the sum of all items within column D of that block. Within each block I am checking the value of the cell in column C and if it contains the letter "y" and the value in column D of that row is equal to zero I must exclude the total sum of column D. Currently I am doing this by multiplying the sum value by either 1 or 0 which is produced by running a test over the cell contents. Below is an example of what I am using to test rows 23 to row 25 inclusively for data in Column D. I am also performing the same on Column E and G, but the "y" character is always in column C, hence the absolut column reference. =IF(AND($C23="y",D23=0),0,1)*IF(AND($C24="y",D24=0),0,1)*IF(AND($C25="y",D25=0),0,1) There must be a more efficient way to do this. Ideally I would like to write a function that I can paste into a cell and then select the rows or cells over which I run the test. Can anyone point me in the right direction?

    Read the article

  • update record only works when there is no auto_increment

    - by every_answer_gets_a_point
    i am accessing a mysql table through an odbc connection in excel here is how i am updating the table: With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("analystname") = aname .Fields("reportname") = rname .Fields("batchstate") = "bstate" .Fields("instrument") = "NA" .Update ' stores the new record End With when the schema of the table is this, updating it works: create table batchinfo(datapath text,analysistime text,reporttime text,lastcalib text,analystname text, reportname text, batchstate text, instrument text); but when i have auto_increment in there it does not work: CREATE TABLE batchinfo ( rowid int(11) NOT NULL AUTO_INCREMENT, datapath text, analysistime text, reporttime text, lastcalib text, analystname text, reportname text, batchstate text, instrument text, PRIMARY KEY (rowid) ) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=latin1 has anyone experienced a problem like this where updating does not work when there is an auto_increment field involved? connection string: Private Sub ConnectDB() Set oConn = New ADODB.Connection oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _ "SERVER=localhost;" & _ "DATABASE=employees;" & _ "USER=root;" & _ "PASSWORD=pas;" & _ "Option=3" End Sub also here's the rs.open: rs.Open "batchinfo", oConn, adOpenKeyset, adLockOptimistic, adCmdTable

    Read the article

  • access: control source of textbox

    - by I__
    there is a form where a user enters a date in [Text4] when users clicks OK, the following code is run: DoCmd.OpenReport "All_Ones", acViewPreview the following is the control source of a textbox on the report [Forms]![By Number]![Text4] for some reason after the report is open, it just sayd #?nameor something like that, meaning that it is an invalid parameter. what am i doing wrong?

    Read the article

  • what is the probability that the next random number will equal current one?

    - by I__
    if i do this in a worksheet: =RAND() i also specified that i want only 2 decimal places and for example let's say that rand() = 0.07 what is the probability that when i call this function again i will get 0.07 ?? i know that ideally if we assume 100% randomness, the answer would be 1/ (10 * 10) because there are only 100 possible combinations, but what would it be according to the way excel generates a random number?

    Read the article

  • Excel assign copied sheet name as variable

    - by rach-90
    I'm trying to copy an existing sheet in my workbook and then I want to use the copied sheet to run the rest of my code. (Sheet3 is the existing sheet, S_Temp is the copied sheet) Dim s_Temp as string Sheet3.copy Activesheet.name = S_Temp Sheets("S_Temp").Range("A1").value = "Test" How can I reference to the copied sheet?

    Read the article

  • what does select @@identity do?

    - by every_answer_gets_a_point
    i am connecting to a mysql database through excel using odbc what does this line do? Set rs = oConn.Execute("SELECT @@identity", , adCmdText) i am having trouble updating the database: With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("analystname") = aname .Fields("reportname") = rname .Fields("batchstate") = "bstate" .Fields("instrument") = "NA" .Update ' stores the new record End With it is ONLY updating .Fields("instrument") = "NA", but for all other fields it is putting NULL values

    Read the article

  • How to set a cell value = to whats looping?

    - by digitalgavakie
    I have this code below. How can I set a cell value to = whats looping through that value? Sub Test2() ' Select cell A2, *first line of data*. Range("A2").Select ' Set Do loop to stop when an empty cell is reached. Do Until IsEmpty(ActiveCell) ' Insert your code here. ' Step down 1 row from present location. ActiveCell.Offset(1, 0).Select Loop End Sub

    Read the article

  • Upload files from website

    - by Andrew
    All I want to do is allow the user to browse through their folders to look for a file, select it and then press submit which saves the file to my server as well as the path to the saved file. How would someone do this? (Some sort of tutorial website would help a lot)

    Read the article

  • mysql NO_AUTO_VALUE_ON_ZERO problem

    - by every_answer_gets_a_point
    at least i think that is what the problem is. i am updating a mysql database through excel using an odbc like this: With rs .AddNew ' create a new record ' add values to each field in the record .Fields("datapath") = dpath .Fields("analysistime") = atime .Fields("reporttime") = rtime .Fields("lastcalib") = lcalib .Fields("analystname") = aname .Fields("reportname") = rname .Fields("batchstate") = "bstate" .Fields("instrument") = "NA" .Update ' stores the new record End With besides the fields above, i also have a primary key auto_increment field called rowid for some reason the only field that gets updated is instrument. none of the other fields get updated.. however, when i try to do the same updating on a table that has no ROWID auto_increment field, it works perfectly has anyone else experienced this kind of issue before?

    Read the article

  • How to match data between columns to do the comparasion

    - by NCC
    I do not really know how to explain this in a clear manner. Please see attached image I have a table with 4 different columns, 2 are identical to each other (NAME and QTY). The goal is to compare the differences between the QTY, however, in order to do it. I must: 1. sort the data 2. match the data item by item This is not a big deal with small table but with 10 thousand rows, it takes me a few days to do it. Pleas help me, I appreciate. My logic is: 1. Sorted the first two columns (NAME and QTY) 2. For each value of second two columns (NAME and QTY), check if it match with first two column. If true, the insert the value. 3. For values are not matched, insert to new rows with offset from the rows that are in first two columns but not in second two columns

    Read the article

  • Excel: Automating the Selection of an Unknown Number of Cells

    - by user1905080
    I’m trying to automate the formatting of an excel file by a macro and am seeking a solution. I have two columns titled Last Name and First Name which I would like to concatenate into a separate column titled Last Name, First Name. This is simple enough when done by hand: create one cell which does this, then drag that cell to include all cells within the range. The problem appears when trying to automate this. Because I can’t know the number of names that need to be concatenated ahead of time, I can’t automate the selection of cells by dragging. Can you help me automate this? I’ve tried a process of copying the initial concatenated cell, highlighting the column, and then pasting. I’ve also tried to use a formula which returned the concatenation only if there is text in the “Last Name” and “First Name” columns. However, in both cases, I end up with some 100,000 rows, putting a serious cramp on my ability to manipulate the worksheet. The best solution I can think of is to create concatenations within a fixed range of cells. Although this would create useless cells, at least there wouldn’t be 99,900 of them.

    Read the article

< Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >