excel-vba

Getting user input through vba

与世无争的帅哥 提交于 2020-01-17 07:52:18
问题 I have a set of dates in Col K in sheet "Latency". I need the user to input the current date and then the code should find all the dates before the entered date, copy the entire row and paste it in a different sheet named "Previous". I'm stuck with how to get input from user and integrate it in code and execute the above. Any suggestions are welcome. 回答1: You could use an input box to get the user to input a date, check that what is entered is actually a date, and then run the code you want:

Spelling check in user form in VBA

走远了吗. 提交于 2020-01-17 07:20:12
问题 I want to check spelling in all labels that I have in a user form in VBA. I would appreciate it if anyone could help me. 回答1: Private Sub UserForm_Initialize() Dim ctrl As Object For Each ctrl In Me.Controls If TypeName(ctrl) = "Label" Then With ctrl If Not Application.CheckSpelling(.Caption) Then .ForeColor = vbRed .BackColor = vbYellow End If End With End If Next End Sub 来源: https://stackoverflow.com/questions/38965880/spelling-check-in-user-form-in-vba

Search Multiple different string in excel VBA

前提是你 提交于 2020-01-17 07:00:34
问题 i am trying to allow the user to search up to 6 different types of strings( text). However i have tried it for up to 2 , Problem but my code only performs the search correctly for the first one. However any of the searches after fisrt string are not achieving the objective. Objective The objective of the code is for it to find the string in the speficied row, then search that coloumn for values greater than zero, if so copy the whole row. Private Sub btnUpdateEntry_Click() Dim StringToFind As

VBA equivalent to Excel's “Search()”

拈花ヽ惹草 提交于 2020-01-17 06:36:41
问题 I have an assignment I need some help with. There are three columns: Column A(username), Column B(Category), and Column C(note). I have to create a Sub that checks each cell down Column B according to category (for example Admin). If the string, "Admin", is found in B2 for example, then the A2 is searched for either:"john.deer", "BES", or "mars". If "john.deer" is found then C2 is to say "Domain Admin Account", if "BES" is found then C2 is to say "BES Admin Account" etc. However if "Admin" is

Excel Code Blocking other Excel Sheets from opening

只谈情不闲聊 提交于 2020-01-17 06:25:39
问题 My Excel file blocks other Excels files from opening. I have the below code Public Sub Workbook_Open() Application.OnTime Now + TimeValue("00:00:03"), "CommonWorkBook.prepareSheets" End Sub In PrepareSheets Macro, I take data from a txt file every 60 seconds. The code is as follows Do While 1 = 1 ' Do Something pause 60 Loop After opening my .xlsm file, I am unable to open other .xlsm files. If I close my .xlsm file, other files gets opened. 回答1: The problem is that when Pause is running it

Excel Code Blocking other Excel Sheets from opening

不羁岁月 提交于 2020-01-17 06:25:03
问题 My Excel file blocks other Excels files from opening. I have the below code Public Sub Workbook_Open() Application.OnTime Now + TimeValue("00:00:03"), "CommonWorkBook.prepareSheets" End Sub In PrepareSheets Macro, I take data from a txt file every 60 seconds. The code is as follows Do While 1 = 1 ' Do Something pause 60 Loop After opening my .xlsm file, I am unable to open other .xlsm files. If I close my .xlsm file, other files gets opened. 回答1: The problem is that when Pause is running it

Autofilter Excel with VBA

こ雲淡風輕ζ 提交于 2020-01-17 06:16:08
问题 I would like to open Excel from Access and apply filters to a sheet. Below is my code: Dim s as String Set oApp = CreateObject("Excel.Application") oApp.Wworkbooks.Open FileName:="dudel.xlsm" oApp.Visible = True s = "AB" With oApp .Rows("2:2").Select .Selection.AutoFilter .ActiveSheet.Range("$A$2:$D$9000").AutoFilter Field:=3, Criteria1:= _ Array(s, "E", "="), Operator:=xlFilterValues .Range("A3").Select End With When I ran the code, I got this error: runt time error 1004 Autofilter methond

Use Index Match to pull multiple columns of data

跟風遠走 提交于 2020-01-17 05:49:38
问题 The following script allows users to perform an Index Match function through a series of Input Boxes. This version only allows users to pull one column of data per use. I'm wondering if its possible to change this code to allow users to pull multiple columns of data. I appreciate any feedback the community can provide. Sub MatchMaster() 'this script helps simplify the use of Excel's Index Match function 'place this script in your personal macro workbook and assign it to a button 'use it to

VBA to change the name of the Activex button

ⅰ亾dé卋堺 提交于 2020-01-17 05:43:06
问题 I am not sure, even if this is possible. I would like to change the named of the button when clicked. I have Active X button that will enable cells on the sheet when clicked. Name of the button "Enable Sheet". Once he enables, he should see a button "Disable Sheet". Please advise. 回答1: assuming your button is named after "CommandButton1": Private Sub CommandButton1_Click() With Me.OLEObjects("CommandButton1").Object .Caption = IIf(.Caption = "Enable Sheet", "Disable Sheet", "Enable Sheet")

Error - SQL coding as “Application-defined or object-defined error”

ε祈祈猫儿з 提交于 2020-01-17 05:37:17
问题 I am relatively experienced in VBA coding, but I am totally new in MS SQL server 2008. I am trying to export an Excel table like below to a SQL server: A B C D E 1 Name Year ID 2 Jill 2015 17 3 Jack 2012 13 4 Mike 1999 25 5 My code below, first creates and opens a connection, then creates a table from the Excel-sheet (Sheet2), then it copies this table to my SQL-server. However, I am getting error like "Application-defined or object-defined error" for the code-line MyWorkBook.CurSheet