vba

Access VBA code in report gives the same result for each row

随声附和 提交于 2021-02-17 05:53:45
问题 This is my report: I have coded in VBA so that the 3rd column (texbox) shows the ID related to each MinDeNote . But it just shows 3 for all row. 3 is the ID of the first product, not all of them. How could I do to make a loop? Thanks ! This is my code: Me!Texte7 = DLookup("F_Code", "Query", "Note = """ & [MinDeNoteBox] & """") The outcome is gonna be different for each row, which is not the case now. 来源: https://stackoverflow.com/questions/65658180/access-vba-code-in-report-gives-the-same

vba check if directory exists, if exists exit sub else if does not exist, create

徘徊边缘 提交于 2021-02-17 05:21:13
问题 Ok so I have the following vba code which I am using to check if a directory exists and if not create the folder structure like so: If Dir("S:\Tasks\" & Range("C" & ActiveCell.Row).Value & "\" & Range("M" & ActiveCell.Row).Value & "\" & Range("Z" & ActiveCell.Row).Value, vbDirectory) = "" Then MkDir Path:="S:\Tasks\" & Range("C" & ActiveCell.Row).Value & "\" & Range("M" & ActiveCell.Row).Value & "\" & Range("Z" & ActiveCell.Row).Value MsgBox "Done" Else MsgBox "found it" End If So my

Use Variable in multiple subs VBA

一世执手 提交于 2021-02-17 04:51:15
问题 So I'm using excel 2010, and right now, I'm trying to use calculate the value of a variable in one sub, and want it to be used in multiple subs, except I can't figure out how to do this. Here is an example of what I'm using in its most basic form Public Sub Calc() Dim i As Integer i = 10 - 5 End Sub 'Other sub that will use the value for i calculated in the Calc sub Sub Macro() y = i +5 End Sub How am I suppose to be able to use/pass this value for "i" in/into the sub macro? 回答1: Move the Dim

Change colour of words with capital letter [closed]

落爺英雄遲暮 提交于 2021-02-17 04:41:25
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . Improve this question I have a table with lots of word and need find words with capital letter and change its colour. For example: A1: event A2: Event A3: Happy day and should change the colour of the words to red in A2 and A3 but in A3 just the "Happy" word. I tried to solve

Change colour of words with capital letter [closed]

ⅰ亾dé卋堺 提交于 2021-02-17 04:39:38
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . Improve this question I have a table with lots of word and need find words with capital letter and change its colour. For example: A1: event A2: Event A3: Happy day and should change the colour of the words to red in A2 and A3 but in A3 just the "Happy" word. I tried to solve

Change colour of words with capital letter [closed]

▼魔方 西西 提交于 2021-02-17 04:39:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago . Improve this question I have a table with lots of word and need find words with capital letter and change its colour. For example: A1: event A2: Event A3: Happy day and should change the colour of the words to red in A2 and A3 but in A3 just the "Happy" word. I tried to solve

VBA Run-time error 438 appears when “paste” runs

血红的双手。 提交于 2021-02-17 03:22:19
问题 I'm just getting familiar with VBA and my code For k = 3 To ThisWorkbook.Sheets.Count ThisWorkbook.Sheets(k).Activate ActiveSheet.Cells(11, 2).Select lLastRow = Cells(Rows.Count, 1).End(xlUp).Row ActiveSheet.Range("A5:" & "A" & CStr(lLastRow)).Copy ' ThisWorkbook.Sheets(1).Cells("B" & CStr(lFirstRow) & ":B" & CStr(lLastRow)).Select ThisWorkbook.Sheets(1).Activate ActiveSheet.Cells(lFirstRow, 2).Select Selection.Paste 'Selection.PasteSpecial Paste:=xlPasteValues 'Selection.PasteSpecial Paste:

VBA Variable as CommandButton#

强颜欢笑 提交于 2021-02-17 02:48:51
问题 I'm rewriting some code and had a thought, but can't seem to get my syntax right to execute it properly. I want to use a for loop to populate an array of commandbuttons as well as control their visibility. I just need help with my syntax to define which CommandButton number I'm working on in the loop. For instance, CommandButton1, CommandButton2, etc. Public Sub LoadLots(sName As String, streamLots() As String) Label1.Caption = sName For o = 1 To 9 If streamLots(o) <> "" Then CommandButton& o

Edit a workbook, whether open or closed, from Word VBA

安稳与你 提交于 2021-02-17 02:48:36
问题 I am trying to write a macro in Word so that I can save some information into an Excel file somewhere else in my computer. For this reason I wrote this: Dim exlApp As Object Dim exlWbk As Object Set exlApp = CreateObject("Excel.Application") Set exlWbk = exlApp.Workbooks.Open(FileName:="D:\database.xlsx") exlWbk.ActiveSheet.Cells(1, 1).Value = "some info" exlWbk.Close SaveChanges:=True Set exlWbk = Nothing exlApp.Quit Set exlApp = Nothing The code works perfectly fine for me, except when the

Edit a workbook, whether open or closed, from Word VBA

北战南征 提交于 2021-02-17 02:47:26
问题 I am trying to write a macro in Word so that I can save some information into an Excel file somewhere else in my computer. For this reason I wrote this: Dim exlApp As Object Dim exlWbk As Object Set exlApp = CreateObject("Excel.Application") Set exlWbk = exlApp.Workbooks.Open(FileName:="D:\database.xlsx") exlWbk.ActiveSheet.Cells(1, 1).Value = "some info" exlWbk.Close SaveChanges:=True Set exlWbk = Nothing exlApp.Quit Set exlApp = Nothing The code works perfectly fine for me, except when the