excel-vba

How to find lost userform control

喜夏-厌秋 提交于 2020-01-03 03:29:06
问题 I have a userform with a bunch of frames. I accidentally dropped a checkbox into one of those frames and it is now nowhere to be found. It still exists, because I'm able to set the value of it with the code, but I can't see it. I tried expanding the frame and also moving the things in the frame (in case it went behind one of those controls). How can I pull it back out? 回答1: This will tell you the position of the checkbox within the frame: Private Sub UserForm_Initialize() Debug.Print Me

VBA - Upload data from Excel to Access without Access installed

旧时模样 提交于 2020-01-03 03:24:09
问题 I am fairly new to VBA but am trying to upload data from an Excel Workbook to an Access database table from a computer that does not have Access installed. I have searched for a solution online but haven't found anything yet that I can get to work with my code. The error code I am getting is...429 cannot create activex component I have some VBA code set up in the Excel workbook which calls a Sub in Access [which works on a machine which has Access installed] but I don't know what the correct

Changing a Worksheet Formula to a VBA formula with worksheet.function

谁说胖子不能爱 提交于 2020-01-03 03:19:07
问题 currently I have a relatively complex workbook formula, which I would like to translate to a vba formula. Currently, I wrote the following but I want it to basically evaluate the function during code execution and insert the value into the required cell. I imagine this is some combination of worksheetfunction but I am unsure of how to translate this Code (doesnt work) MWS.Cells(LastMWSR + 1, ClastMWSC).Value = WorksheetFunction.SUMIFS(mws.range(N:N),mws.Range(B:B),worksheetfunction.INDEX(mws

how to read certain files in a directory in excel VBA

眉间皱痕 提交于 2020-01-03 03:14:35
问题 I want to read certain excel files from a directory and then open them in excel-2007 with VBA. Here is an example: directory: c:\temp file pattern: is xxxxx0123.xls (xxxxx represents the file names). I try to use Application.FileSearch , but it won't work in Excel 2007. Does any one have good suggestions? Thanks in advance 回答1: You can use DIR to find files matching your pattern, ie this code opens these files, grabs their path, and closes the files again The code can be made recursive if you

Excel VBA print to specific printer tray

六月ゝ 毕业季﹏ 提交于 2020-01-03 03:09:07
问题 In Excel (2007) VBA how do I print the worksheet to a specific printer tray? This will just print to the default tray on the printer: ws.PrintOut ActivePrinter:="\\print_server\printer_name" 回答1: Microsoft offers one ugly solution to this problem; using SendKeys to manually choose the correct tray from the print settings dialog box. Another option may be to set up additional printers in Windows, where each printer is actually linked to a different tray on the same printer. You could then

Preserve formatting of Word table in Excel VBA

落花浮王杯 提交于 2020-01-03 03:05:27
问题 From another discussion, I was able to find this macro that imports a table from Word into Excel. It works great but how I can make it keep the formatting of the Word table? I have tried a few ways but can't quite get it working. Also is there a way to do more files at once and not just 1 at a time? Option Explicit Sub ImportWordTable() Dim wdDoc As Object Dim wdFileName As Variant Dim tableNo As Integer 'table number in Word Dim iRow As Long 'row index in Excel Dim iCol As Integer 'column

Using ADO to query text files - terrible performance

こ雲淡風輕ζ 提交于 2020-01-03 02:54:14
问题 I'm writing some code in VBA behind Excel to pull some summary numbers out of potentially huge text files (10M+ rows) out on a network drive. In the past, these numbers have been pulled using greps in linux, but I was hoping to implement something that could be done with a click of a button in Excel for ease of use. My solution works, but it's like 25 times slower than a linux grep - takes 4 minutes to query 10M records, while the grep can do it in 10 seconds. Should I not be using ADO for

Index multiple columns and Match distinct values, returning list of unique values across columns

人走茶凉 提交于 2020-01-03 02:50:10
问题 I've searched far and wide for a solution to my problem... over several long weeks now. I've come up a partially working solutions, which I'll include at the bottom for those who might know how to modify/extend them to resolve the problem. Here's what I'm trying to accomplish (the following descriptions are in reference to this screen capture http://imgur.com/oTkbjrw): 1) I am looking to match values from Column G with Column A ($G2 with $A$2:$A$10). 2) If the values match, then extract

VBA - select specific sheets within workbook to loop through

ⅰ亾dé卋堺 提交于 2020-01-03 02:48:05
问题 I have an excel workbook with a variable number of sheets. At the moment I am looping through all sheets and therein a specific column to search for figures above a certain threshold. Column and threshold are determined by inputboxes that need to be filled in by the user. If the figure in the column, let's say column "J" and row 10 is above threshold, row 10 is copied and pasted in a new created "summary" sheet etc. I am struggling at the moment with a specific selection of sheets. I don't

VBA - Value of an option button in a frame (within an Excel sheet)

我的未来我决定 提交于 2020-01-03 02:40:14
问题 I'm having problems with shapes, frames and option buttons... I'm a total newbie, I've never used them. I just put several option buttons on an Excel sheet (Using the FORM toolbox). I'm trying to check whether my optionbutton is filled or not. So far, I've done the following : Sub SX_EXTERNE() Dim Ws As Worksheet Dim ConBut As Shape Dim Answer As String Set Ws = ThisWorkbook.Sheets("Externe") For Each ConBut In Ws.Shapes If ConBut.Type = msoFormControl Then If ConBut.FormControlType =