excel-vba

VBScript to loop through Excel-files and change macro

拥有回忆 提交于 2020-01-03 06:07:03
问题 I already posted a closely related question last week VBScript to add code to Excel workbook which got solved by a fellow programmer. But I ran into the next problem with that task: With the following code, I try to loop through a folder of Excel files then open them one by one and change the macro in DieseArbeitsmappe . This works fine for the first file but the second ends with this error message. Error message Set objFSO = CreateObject("Scripting.FileSystemObject") sFolder = "P:

VBScript to loop through Excel-files and change macro

无人久伴 提交于 2020-01-03 06:06:07
问题 I already posted a closely related question last week VBScript to add code to Excel workbook which got solved by a fellow programmer. But I ran into the next problem with that task: With the following code, I try to loop through a folder of Excel files then open them one by one and change the macro in DieseArbeitsmappe . This works fine for the first file but the second ends with this error message. Error message Set objFSO = CreateObject("Scripting.FileSystemObject") sFolder = "P:

VBA Excel Copy Clipboard data to array

会有一股神秘感。 提交于 2020-01-03 06:02:11
问题 I am working in a project where i have to to copy some text from a web page using Crt A + Crt C then i want to use this Data in Excel the copyed text is about 100 lines with defrent sizes let say on line has a string of 200 chart and the next one has 500 chart . And the 3rd maybe 20 Is there a way to loop over the clipboard Data line and copy them to an array ? i add the sample of the copied (Making Crt A Crt C in the page ) text: Note : I removed some Lines Usernames are XXXXXXXXXXXXXXXXX

Get path, filename, sheet and address of defined name in closed workbook

余生长醉 提交于 2020-01-03 06:00:15
问题 This code can add a defined name to another workbook perfectly fine: Sub AddDefinedName() Dim sPath As String Dim sFilename As String Dim sSheetname As String Dim sRangeAddress As String sPath = "C:\Me\Folder" sFilename = "source.xls" sSheetname = "Sheet1" sRangeAddress = "$A$1:$B$5" ThisWorkbook.Names.Add "Source", _ RefersTo:="='" & sPath & "\[" & sFilename & "]" & sSheetname & "'!" & sRangeAddress End Sub And this code allows to get all the information IF the said workbook is open: Sub

Get all list of possible filter criteria

让人想犯罪 __ 提交于 2020-01-03 05:53:24
问题 From VBA I need to know the list of all criteria that I can choose in filtering columns. For example the following list: [1-ALFA;2-BETA;...5-ETC] 回答1: Say we have data like: and we filter size for large and we want to list the criteria for column A : Sub ShowCriteria() Dim r As Range, c1 As Collection, c2 As Collection Dim msg As String Set c1 = New Collection Set c2 = New Collection Dim LastRow As Integer With Worksheets("sheet1") LastRow = .Range("A" & Worksheets("sheet1").Rows.Count).End

Get all list of possible filter criteria

我的梦境 提交于 2020-01-03 05:53:02
问题 From VBA I need to know the list of all criteria that I can choose in filtering columns. For example the following list: [1-ALFA;2-BETA;...5-ETC] 回答1: Say we have data like: and we filter size for large and we want to list the criteria for column A : Sub ShowCriteria() Dim r As Range, c1 As Collection, c2 As Collection Dim msg As String Set c1 = New Collection Set c2 = New Collection Dim LastRow As Integer With Worksheets("sheet1") LastRow = .Range("A" & Worksheets("sheet1").Rows.Count).End

Count number of rows in multiple Excel sheets and return values to a “summary” sheet

ⅰ亾dé卋堺 提交于 2020-01-03 05:46:09
问题 I have an Excel workbook with 10 plus sheets. On the "Summary" sheet I want to summarise how many rows are used on each of the other sheets. I'm thinking that a Function that gets called multiple times is the most efficient. If this is so, then I think it starts something like; Function CountMyRows(SName) # where SName is the name of a sheet Dim rowCount As Integer rowCount = Worksheets("SName").Rows.Count Am I starting in the right direction? 回答1: Place the following two Functions into a

Excel VBA import data to existing Access database

时间秒杀一切 提交于 2020-01-03 05:41:06
问题 I've found similar questions asked before, but I can't seem to figure it out using those examples. I'm writing a macro in Excel where the last step needs to import all the data in Sheet1!A:Q (headers in row 1) to Table1 in an Access database. I need to make sure each column in Excel corresponds to the correct field in Access. I am using Excel 2010/2013 and Access 2010/2013. Code I am currently using is: Sub AccImport() Dim acc As New Access.Application acc.OpenCurrentDatabase "C:\Users

How do I prompt the user to select the file and sheet, when using macro to import a data file?

与世无争的帅哥 提交于 2020-01-03 05:39:07
问题 I have a macro that is currently creates a new sheet, and imports another Excel file into this new sheet. Data from this sheet is then pulled into other areas of the workbook. The file that is being imported has several tabs and will constantly have a different file name. How do I adjust the below code to prompt the user to select the file AND the appropriate tab? (The directory will not change.) I tried using the FileDialog object, but it doesn't seem that Excel takes any action on the file

How to add text to last row of a column

非 Y 不嫁゛ 提交于 2020-01-03 05:37:09
问题 Please I need some help with how to add text to the last (empty) row in a column using VBA? I have a spreedsheet with an ActiveX Control button on it. I want that on clicking the command button, Excel takes the text contained in say, cell C3, and add it to the last (empty) row of column A. Please note that Column A already contains text in various cells. What I want to do is find the last empty cell and then transfer the text from cell C3 to this last empty row. Thank you. 回答1: Assign this