vba

Auto-Decline Meeting Invite Run-Time Error 91: Object variable or With block variable not set

限于喜欢 提交于 2021-01-29 19:52:04
问题 I found the code for Auto-Decline a meeting request in several locations. In my Outlook 2013 as an action for a rule, it is stopping on the line intended to discard instead of sending the reply. The meeting organizer does not need a response from everyone. As it is on the group calendar, I don't need it on my personal as they are not meetings I get involved with. The Outlook rule is aborting the script and jumping out before a couple of additional actions (mark as read and delete) when it

Need to transpose the vertical data to horizontal format, but few cells in Vertical format can have more than 2 or 3 sub categories in Excel VBA

喜欢而已 提交于 2021-01-29 19:35:58
问题 This is BEFORE image This is AFTER Image 回答1: It is based on the assumption that your original data is still listed in the column direction. Sub test2() Dim Ws As Worksheet Dim toWs As Worksheet Dim vDB, vR() Dim rngDB As Range Dim i As Long, j As Long, n As Long Dim r As Long, c As Long, k As Long Set Ws = Sheets(1) Set toWs = Sheets(2) Set rngDB = Ws.Range("a1").CurrentRegion vDB = rngDB r = UBound(vDB, 1) c = UBound(vDB, 2) For j = 2 To c n = n + 1 'ReDim Preserve vR(1 To 4, 1 To n) ReDim

Restrict Worksheet_Change to a specified range of cells

痴心易碎 提交于 2021-01-29 19:25:30
问题 I want to record a list of live data in a separate sheet. Found this code online which works. How to do I change the range from one cell A1 to a Range A1:D30? Private Sub Worksheet_Change(ByVal Target As Range) Dim dest As Range Application.EnableAnimations = False On Error GoTo line1 If Target.Address <> "$A$1" Then GoTo line1 Set dest = Worksheets("sheet2").Cells(Rows.Count, "a").End(xlUp).Offset(1, 0) 'MsgBox dest.Address Target.Copy dest line1: Application.EnableEvents = True End Sub 回答1:

Excel - ActiveChart.SetSourceData Source: Runtime Error '445' : Object doesn't support this action

不问归期 提交于 2021-01-29 19:01:31
问题 I have an excel workbook (v2016), where I managed to get the table name of a table based on the highest number of entries. This value (which is a name of a table) is in Sheet "Pareto" Cell B4. I'm using the following code to update a chart using an above-mentioned table name Sub GetTables() Dim YTDL1TableName As String Dim YTDL1Range As Range YTDL1TableName = Sheets("Pareto").Range("B4") Set YTDL1Range = Sheets("Pareto").Range(Sheets("Pareto").ListObjects(YTDL1TableName).Range.Address(True,

Find, select, and copy row

假装没事ソ 提交于 2021-01-29 18:32:50
问题 How do I find a cell containing a certain string in a certain column, then select the entire row and copy that row using Excel vba? I am relatively new to using Excel VBA and have spent days trying to code this myself. I am working on a worksheet in which different datasets are copied into. Every data set will contain the string "page" in some cell of column A, however the row varies from dataset to dataset. I now need some vba code to first identify the cell of column A that contains the

Error with copy paste due to merged column cells

跟風遠走 提交于 2021-01-29 18:32:26
问题 I want to copy paste values from 4 columns in one worksheet into 4 columns of another worksheet depending on whether the values in a single column are null or not. Following is my code: Private Sub CommandButton1_Click() Dim lastrow As Long, erow As Long lastrow = Worksheets("jun").Cells(Rows.Count, 1).End(xlUp).Row erow = 20 For i = 8 To lastrow If Worksheets("jun").Cells(i, 16).Value <> "" Then Worksheets("jun").Cells(i, 16).Copy Worksheets("jun").Paste Destination:=Worksheets("test").Cells

Webscrap VBA - List

余生长醉 提交于 2021-01-29 18:31:17
问题 I am trying to set up a webscrapping VBA code to import data into Excel from this website: https://www.thewindpower.net/windfarms_list_en.php I wish to launch this webpage, select a country and then scrap the data from the table below (including url from the name column). Yet, I am stuck with several points: How can I select the country I wish in VBA code ? How can I select the table as there is no id or class in the tag ? How can I import the URL included in the name column ? Here is the

Finding OS short date format string in MS-Access/VBA

天大地大妈咪最大 提交于 2021-01-29 18:30:52
问题 I am looking for a VBA function that would return the current OS Short date format (ex: M/d/yyyy , dd-MMM-yy , yy/MM/dd , etc.) as a string. I have found such functions for MS Excel on related posts using Application.International , but they do not work with MS Access. I want to be able to show the OS date format in my forms to avoid confusion if '08-11-11' is displayed, for example. Using CDate() , my dates are automatically formatted to whatever is set in Windows Date and time settings.

Require that form fields are filled before saving a record

强颜欢笑 提交于 2021-01-29 18:30:39
问题 I have a form with fourteen fields, ten of which are always required, and three of which ( Other Absence Type , Illness Type and Other Illness Type ) are conditionally required. There is also a Save Record button on the form, which has a subroutine meant to check that all required fields are filled before saving the record. The ten required fields have their Required property set to Yes in the table. The code for enabling/disabling the three conditionally required fields appears to work on

Excel VBA sort Listbox data if not numeric to bottom

ⅰ亾dé卋堺 提交于 2021-01-29 18:30:33
问题 I am using the below code to sot my Listbox data numerically. I use the following IF statement to check if data is numeric (some data is not): If IsNumeric(.List(i, 4)) And IsNumeric(.List(j, 4)) Then My Listbox data is sorted correctly. However because of the above IF statement the sorting process ignores non-numeric data. I need to sort the non numeric data to the bottom of the Listbox. Public Sub BubbleSort() Dim i As Long Dim j As Long Dim Temp4 As Variant, Temp3 As Variant, Temp2 As