Search Results

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

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

  • FilePageSetupHeader in MS Project VBA project: Display image dynamically

    - by Anne Schuessler
    I want to display an image when printing a page from MS Page using the FilePageSetupHeader. It all works fine if I pass in the parameter for the Text property as a string as such FilePageSetupHeader Alignment:=pjRight, Text:="&P""C:\filepath\image.gif""" However, I'd prefer to be able to pass the filepath to the image to display as a variable. Somehow I can't get it right. So if I try something like the following: vImagePath = """&P""""" & prjFilePath & "\image.gif"""""" FilePageSetupHeader Alignment:=pjRight, Text:=vImagePath it just displays the path as a string. I'm pretty sure it boils down to something simple like escaping the quotes in the correct way, but I've been playing around with it for a while now and I can't seem to get it right. Any idea how this works?

    Read the article

  • VBA Excel 2007 macro dies in Excel 2002

    - by Rob A
    Hi, I have just tried to send a workbook to a friend that has a chart with a drop-down box on it. In excel 2007 I have used: If Chart2.Shapes(2).ControlFormat.ListCount = "16" Then To check the size of the list so that it doesnt get entered in again (resulting in an extremely long list that repeats itself). This line works well in Excel 2007, but gives a Object doesn't support this property or method. error in Excel 2002. What is the difference between working with shapes in 2002 vs 2007?

    Read the article

  • Access 2007 VBA : Building a listbox with selection choices from another list box

    - by Justin
    So there are 8 categories that may be associated to each order, but not necessarily all of them. So i was going to build a list box that allowed the user to double click each of the category they wish to associate when they have an "Order Detail" form opened up (unbound form that has hidden text boxes with all needed ID numbers). I want to have another empty text box right beside it that will allow me to append the selections (up to 8) so the user can see that they have been added. So one list box with the default choices, and when a choice is double clicked, it adds that choice to the second list box to see the tally so to speak. What is the VB for getting something like this done? Thanks Justin

    Read the article

  • ACCESS VBA - DAO in VB - problem with creating relations

    - by Justin
    So take the following example: Sub CreateRelation() Dim db As Database Dim rel As Relation Dim fld As Field Set db = CurrentDb Set rel = db.CreateRelation("OrderID", "Orders", "Products") 'refrential integrity rel.Attributes = dbRelationUpdateCascade 'specify the key in the referenced table Set fld = rel.CreateField("OrderID") fld.ForeignName = "OrderID" rel.Fields.Append fld db.Relations.Append rel End Sub I keep getting the error, No unique index found for the referenced field of the primary table. if i include the vb before this sub to create in index on the field, it gives me the error: Index already exists. so i am trying to figure this out. if there are not any primary keys set, will that cause this not to work? i am confused by this, but i really really want to figure this out. So orderID is a FOREIGN KEY in the Products Table please help thanks justin

    Read the article

  • VBA nested Loop flow control

    - by PCGIZMO
    I will be brief and stick to what I know. This code for the most part works as it should. The only issue is in the iteration of the x and z loop. these to loops should set the range and yLABEL for the Y loop. I can get through a set and come up with the correct range after that things go bonkers. I know some of it has to do with not breaking out of x to set z and then back to x update the range. It should work z is found then x. the range between them is set for y. then next x but y stays then rang between y and x is set for y.. so on and so forth kinda like a slinky down the stairs. or a slide rule depending on how I set the loops either way I end up all over the place after a couple iterations. I have done a few things but each time I break out of x to set z , X restarts at the top of the range. At least that's what I think I am seeing. In the example sheet i have since changed the way the way the offset works with the loop but the idea is still the same. I have goto statements at this time i was going to try figuring out conditional switches after the loops were working. Any help direction or advice is appreciated. Option Explicit Sub parse() Application.DisplayAlerts = False 'Application.EnableCancelKey = xlDisabled Dim strPath As String, strPathused As String strPath = "C:\clerk plan2" Dim objfso As FileSystemObject, objFolder As Folder, objfile As Object Set objfso = CreateObject("Scripting.FileSystemObject") Set objFolder = objfso.GetFolder(strPath) 'Loop through objWorkBooks For Each objfile In objFolder.Files If objfso.GetExtensionName(objfile.Path) = "xlsx" Then Dim objWorkbook As Workbook Set objWorkbook = Workbooks.Open(objfile.Path) ' Set path for move to at end of script strPathused = "C:\prodplan\used\" & objWorkbook.Name objWorkbook.Worksheets("inbound transfer sheet").Activate objWorkbook.Worksheets("inbound transfer sheet").Cells.UnMerge 'Range management WB Dim SRCwb As Worksheet, SRCrange1 As Range, SRCrange2 As Range, lastrow As Range Set SRCwb = objWorkbook.Worksheets("inbound transfer sheet") Set SRCrange1 = SRCwb.Range("g3:g150") Set SRCrange2 = SRCwb.Range("a1:a150") Dim DSTws As Worksheet Set DSTws = Workbooks("clerkplan2.xlsm").Worksheets("transfer") Dim STR1 As String, STR2 As String, xVAL As String, zVAL As String, xSTR As String, zSTR As String STR1 = "INBOUND TRANS" STR2 = "INBOUND CA TRANS" Dim x As Variant, z As Variant, y As Variant, zxRANGE As Range For Each z In SRCrange2 zSTR = Mid(z, 1, 16) If zSTR <> STR2 Then GoTo zNEXT If zSTR = STR2 Then zVAL = z End If For Each x In SRCrange2 xSTR = Mid(x, 1, 13) If xSTR <> STR1 Then GoTo xNEXT If xSTR = STR1 Then xVAL = x End If Dim yLABEL As String If xVAL = x And zVAL = z Then If x.Row > z.Row Then Set zxRANGE = SRCwb.Range(x.Offset(1, 0).Address & " : " & z.Offset(-1, 0).Address) yLABEL = z.Value Else Set zxRANGE = SRCwb.Range(z.Offset(-1, 0).Address & " : " & x.Offset(1, 0).Address) yLABEL = x.Value End If End If MsgBox zxRANGE.Address ' DEBUG For Each y In zxRANGE If y.Offset(0, 6) = "Temp" Or y.Offset(0, 14) = "Begin Time" Or y.Offset(0, 15) = "End Time" Or _ Len(y.Offset(0, 6)) = 0 Or Len(y.Offset(0, 14)) = 0 Or Len(y.Offset(0, 15)) = "0" Then yNEXT Set lastrow = Workbooks("clerkplan2.xlsm").Worksheets("transfer").Range("c" & DSTws.Rows.Count).End(xlUp).Offset(1, 0) y.Offset(0, 6).Copy lastrow.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=True, Transpose:=False DSTws.Activate ActiveCell.Offset(0, -1) = objWorkbook.Name ActiveCell.Offset(0, -2) = yLABEL objWorkbook.Activate y.Offset(0, 14).Copy Set lastrow = Workbooks("clerkplan2.xlsm").Worksheets("transfer").Range("d" & DSTws.Rows.Count).End(xlUp).Offset(1, 0) lastrow.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=True, Transpose:=False objWorkbook.Activate y.Offset(0, 15).Copy Set lastrow = Workbooks("clerkplan2.xlsm").Worksheets("transfer").Range("e" & DSTws.Rows.Count).End(xlUp).Offset(1, 0) lastrow.PasteSpecial Paste:=xlPasteValues, operation:=xlNone, skipblanks:=True, Transpose:=False yNEXT: Next y xNEXT: Next x zNEXT: Next z strPathused = "C:\clerk plan2\used\" & objWorkbook.Name objWorkbook.Close False 'Move proccesed file to new Dir Dim OldFilePath As String Dim NewFilePath As String OldFilePath = objfile 'original file location NewFilePath = strPathused ' new file location Name OldFilePath As NewFilePath ' move the file End If Next End Sub

    Read the article

  • Access 2003 VBA: Return only the index of the last item selected in a ListBox

    - by Eric D. Johnson
    I will preface this with saying, this is my first time using listboxes and earlier posts were criticized for lacking detail. So, all help is greatly appreciated and I hope this is enough information without being overkill. Currently, I have a listbox updating a junction table with an on click event (iterates through selected items and if they are not in the table it adds them). The list box is also updated by an option group (based on the option group value a query populates the list with the appropriate items and they are selected/highlighted based on the junction table). Also, when items are a "sub-category" the "category" is also selected. This functions perfectly until I ask it to do more... Problem 1: I need to differentiate "categories" of items from each other. So, I have included a blank item to the list box to add a space between categories. When the blank items are present the listbox does not update the junction table properly and vice versa. Problem 2: My users want to be able to deselect the "category" under certain circumstances. This is fine, just de-select the "category" after the "sub-category" is selected. However, the "category" is re-selected whenever the listbox is clicked again because it iterates through all entries. Perceived solution for both problems: Return only the index of the item (de)selected and manipulate accordingly. Is this possible? If so, how? OR: Should I take a different approach?

    Read the article

  • Redimming arrays in VBA

    - by Mike
    I have 3 arrays of data, that are filled by reading off of an excel sheet, some of the points of data are missing and as such have just been entered into excel as "NA" so I want to look through my array and find each instance of these NA's and remove them from the array since the information is useless. I need to update all three arrays at the same time. Sub group_data() Dim country(), roe(), iCap() As String Dim i As Integer For i = 1 To 3357 country(i) = Workbooks("restcompfirm.xls").Worksheets("Sheet1").Range("C1").Offset(i, 0) roe(i) = Workbooks("restcompfirm.xls").Worksheets("Sheet1").Range("AP1").Offset(i, 0) iCap(i) = Workbooks("restcompfirm.xls").Worksheets("Sheet1").Range("BM1").Offset(i, 0) Next i End Sub So if I find a "NA" as one of the values in roe or iCap I want to get rid of that piece of data in all there arrays.

    Read the article

  • excel vba: return values only if they are not present in current column

    - by every_answer_gets_a_point
    i have a column to which i am adding data from another column i would like to check whether that column has the data that i wish to add. can you help me wiht a formula that will tell me whether a certain value exists in the current column? please keep in mind it is a bit more complex than it sounds. currently i have this in the cell: =IF(OR(A3="ETG_C",A3="ETGC"),C3,"na") i would like to have something like this =IF(FIND(IF(OR(A2="ETG_C",A2="ETGC"),C2,"na"),K:K,1)," ",IF(OR(A2="ETG_C",A2="ETGC"),C2,"na")) another words, if the top value exists already, then add a blank space

    Read the article

  • VBA Excel - Workbook_SheetChange

    - by user2947014
    Hopefully this question hasn't already been asked, I tried searching for an answer and couldn't find anything. This is probably a simple question, but I am writing my first macro in excel and am having a problem that I can't find out a solution to. I wrote a couple of macros that basically sum up columns dynamically (so that the number of rows can change and the formula moves down automatically) based on a value in another column of the same row, and I call those macros from the event Workbook_SheetChange. The problem I'm having is, I change a cell's value from my macro to display the result of the sum, and this then calls Workbook_SheetChange again, which I do not want. Right now it works, but I can trace it and see that Workbook_SheetChange is being called multiple times. This is preventing me from adding other cell changes to the macros, because then it results in an infinite loop. I want the macros to run every time a change is made to the sheet, but I don't see any way around allowing the macros to change a cell's value, so I don't know what to do. I will paste my code below, in case it is helpful. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) Dim Row As Long Dim Col As Long Row = Target.Row Col = Target.Column If Col <> 7 Then Range("G" & Row).Select Selection.Formula = "=IF(F" & Row & "=""Win"",E" & Row & ",IF(F" & Row & "=""Loss"",-D" & Row & ",0))" Target.Select End If Call SumRiskColumn End Sub Private Sub Workbook_SheetCalculate(ByVal Sh As Object) Call SumOutcomeColumn End Sub Sub SumOutcomeColumn() Dim N As Long N = Cells(Rows.Count, "A").End(xlUp).Row Cells(N + 1, "G").Formula = "=SUM(G2:G" & N & ")" End Sub Sub SumRiskColumn() Dim N As Long N = Cells(Rows.Count, "A").End(xlUp).Row Dim CurrTotalRisk As Long CurrTotalRisk = 0 For i = 2 To N If IsEmpty(ActiveSheet.Cells(i, 6)) And Not IsEmpty(ActiveSheet.Cells(i, 1)) And Not IsEmpty(ActiveSheet.Cells(i, 2)) And Not IsEmpty(ActiveSheet.Cells(i, 3)) Then CurrTotalRisk = CurrTotalRisk + ActiveSheet.Cells(i, 4).Value End If Next i Cells(N + 1, "D").Value = CurrTotalRisk End Sub Thank you for any help you can give me! I really appreciate it.

    Read the article

  • Excel 2003 VBA : how to paste a shape after selection

    - by Justin
    Just wondering how I can paste an object after I have selected it: sheet1.shapes("MyShape").select With Selection basically jsut wondering how to duplicate a shape object, or any object really. Eventually I am looking to use code to copy a shape object like above from Excel, and paste it into an access form automatically. Thanks!

    Read the article

  • Copy email to the clipboard with Outlook VBA

    - by Arlen Beiler
    How do I copy an email to the clipboard and then paste it into excel with the tables intact? I am using Outlook 2007 and I want to do the equivalent of "Click on email > Select All > Copy > Switch to Excel > Select Cell > Paste". I have the Excel Object Model pretty well figured out, but have no experience in Outlook other than the following code. Dim mapi As NameSpace Dim msg As Outlook.MailItem Set mapi = Outlook.Application.GetNamespace("MAPI") Set msg = mapi.Folders.Item(1).Folders.Item("Posteingang").Folders.Item(1).Folders.Item(7).Items.Item(526)

    Read the article

  • Excel vba: error hiding calculated field in Pivot table

    - by Patrick Honorez
    I have written several Subs to show/hide fields in a PivotTable. Now I am trying to do the same with a calculated field, but I get an error when hiding it. I took my code from the recorder and the recorder's code also halts on the last line. I googled the error message, without serious result. Sub PrRemove() 'remove PR Dim pt As PivotTable Set pt = ActiveSheet.PivotTables("MyPivot") pt.PivotFields("MyField").Orientation = xlHidden '<- here is the error End Sub The same code works fine if MyField is a normal field (not a calculated one). I am using Excel 2007 with SP2. Any clue ?

    Read the article

  • vba excel: do something every time a certain variable is changed

    - by every_answer_gets_a_point
    im doing a bunch of stuff to the variable St For i = 1 To 30000 Randomize e1 = Rnd e2 = Rnd z1 = Sqr(-2 * Log(e1)) * Cos(2 * 3.14 * e2) z2 = Sqr(-2 * Log(e1)) * Sin(2 * 3.14 * e2) St = So * Exp((r - (sigma ^ 2) / 2) * T + sigma * Sqr(T) * z1) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T - sigma * Sqr(T) * z1) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T + sigma * Sqr(T) * z2) C = C + Application.WorksheetFunction.Max(St - K, 0) St = So * Exp((r - (sigma ^ 2) / 2) * T - sigma * Sqr(T) * z2) C = C + Application.WorksheetFunction.Max(St - K, 0) Next i how do i get notified every time the variable changes?

    Read the article

  • VBA: Validate List settings

    - by stanigator
    Sub Macro1() ' ' Macro1 Macro ' ' Worksheets("Drop-down").Select For i = 1 To 10 ActiveSheet.Cells(i, 2).Select With Selection.Validation .Delete ' Error in this line .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1:=Range(Worksheets("Misc").Cells(2, i), Worksheets("Misc").Cells(2, i).End) .IgnoreBlank = True .InCellDropdown = True .InputTitle = "" .ErrorTitle = "" .InputMessage = "" .ErrorMessage = "" .ShowInput = True .ShowError = True End With Next i End Sub I'm getting an error in the line below the comment, yet I don't know how to fix it. It would be great to hear some suggestions. Thanks in advance!

    Read the article

  • Cutting Row with Data and moving to different sheet VBA

    - by user3709645
    I'm trying to cut a row that has the specified cell blank and then paste it into another sheet in the same workbook. My coding works fine to delete the row but everything I've tried to cut and paste keeps giving me errors. Here's the working code that deletes the rows: Sub Remove() 'Remove No Denovo &/or No Peak Seq Dim n As Long Dim nLastRow As Long Dim nFirstRow As Long Dim lastRow As Integer ActiveSheet.UsedRange Set r = ActiveSheet.UsedRange nLastRow = r.rows.Count + r.Row - 1 nFirstRow = r.Row For n = nLastRow To nFirstRow Step -1 If Cells(n, "G") = "" Then Cells(n, "G").EntireRow.Delete Next n End Sub Thanks for any help!

    Read the article

  • redimension multidimensional arrays in Excel VBA [migrated]

    - by user147178
    Take a look at the following code. What my problem is is that I can't figure out how to redimension the n integer and the b integer. What I'm doing is the array sent1 is already working and it is populated with about 4 sentences. I need to go through each sentence and work on it but I'm having trouble. dim sent1() dim sent2() dim n as integer, b as integer, x as integer dim temp_sent as string b = 0 For n = 1 to ubound(sent1) temp_sent = sent1(n) for x = 1 to len(temp_sent1) code if a then b = b + 1 THIS IS THE PART OF THE CODE THAT IS NOT WORKING redim preserve sent2(1 to ubound(sent1), b) sent2(n,b) = [code] next next

    Read the article

  • Open an Access database and run one of its Macros from Excel

    - by sqlnoob
    From Excel, I need to open an Access database and run one of the database's macros. I'm using Excel and Access 2007. Here is my code in Excel: Sub accessMacro() Dim appAccess As New Access.Application Set appAccess = Access.Application appAccess.OpenCurrentDatabase "C:\blah.mdb" appAccess.Visible = True appAccess.DoCmd.RunMacro "RunQueries.RunQueries" appAccess.CloseCurrentDatabase End Sub In the Access Database, there is a procedure named RunQueries in a module named RunQueries. Each time I run this, I get the following error: Runtime error '2485': Microsoft Access Office can't find the object 'RunQueries.' I have also tried: appAccess.DoCmd.RunMacro "RunQueries" and I get the same errors message. Any idea how to do this? By the way, I could go into a long explanation about why I need to do this, but let me just say that I've already argued against it, and I have to do it this way (meaning, I have to use Excel as a frontend to open several Access dbs and run their macros).

    Read the article

  • How to insert hyperlink into access database via sql?

    - by CSharperWithJava
    I have a fairly simple MS Access Database that contains some metadata about a bunch of documents and a hyperlink field that links to the document on our network drive. However, when I use a SQL INSERT statement to populate the hyperlink field, the value I give it only becomes the display text, not the actual link. How can I make the value a functional hyperlink? I'd think that the hyperlink data type would actually create hyperlinks. I'm using Access 2002 SP3.

    Read the article

  • What is the C# equivalent of this Excel VBA code for Shapes?

    - by code4life
    This is the VBA code for an Excel template, which I'm trying to convert to C# in a VSTO project I'm working on. By the way, it's a VSTO add-in: Dim addedShapes() As Variant ReDim addedShapes(1) addedShapes(1) = aBracket.Name ReDim Preserve addedShapes(UBound(addedShapes) + 1) addedShapes(UBound(addedShapes)) = "unique2" Set tmpShape = Me.Shapes.Range(addedShapes).Group At this point, I'm stumped by the addedShapes(), not sure what this is all about. Update: Matti mentioned that addedShapes() represents a variant array in VBA. So now I'm wondering what the contents of addedShapes() should be. Would this be the correct way to call the Shapes.Range() call in C#? List<string> addedShapes = new List<string>(); ... Shape tmpShape = worksheet.Shapes.get_Range (addedShapes.Cast<object>().ToArray()).Group(); I'd appreciate anyone who's worked with VBA and C# willing to make a comment on my question & problem!

    Read the article

  • How to get the MD5 hex hash for a file using VBA?

    - by aF
    How can I get the MD5 hex hash for a file using VBA? I need a version that works for a file. Something as simple as this Python code: import hashlib def md5_for_file(fileLocation, block_size=2**20): f = open(fileLocation) md5 = hashlib.md5() while True: data = f.read(block_size) if not data: break md5.update(data) f.close() return md5.hexdigest() But in VBA.

    Read the article

  • Return the date of the day under an if formula with Excel or VBA

    - by Celine
    I have two columns A and B and many lines with some specific tasks to be done. In column B, I have a drop-down list with the name of people who are scheduled for the task . And in column A, I want the date of the day the person signed off the task. What should I do in VBA or in Excel so that, for example, when somebody signs off a task in the cell B11, A11 returns me the date of the day. I have used the formula below in A11 =if (B11<"", today(),"") but everytime i open the file the date is updated. So it doesn't allow me to keep track of everybody's work. I tried with vba but couldn't write a function that gives me the right answer. i'm pretty new at vba so i'm sorry if my question sounds stupid

    Read the article

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