excel-vba

Convert VBA to Javascript (Google Apps Script)

北城余情 提交于 2020-04-12 07:41:22
问题 I would like to convert my VBA to something I can use for Google Apps Script. Sub Macro5() ' ' Macro5 Macro ' ' Range("B2").Select Selection.Copy Range("B15").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Application.CutCopyMode = False Rows("15:15").Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Range("B2").Select End Sub And I ended up with this: function Macro5(){ Range("B2").Select; Selection.Copy;

Can you import only the 2nd Sheet from Excel to Access using VBA

笑着哭i 提交于 2020-04-12 06:12:08
问题 Can you import only the 2nd Sheet from Excel to Access using VBA?! I did some Googling on this and couldn't find a definitive answer. Here is the code that I'm trying to get working. strPathFile = Fil objXL.Visible = True Set wkb = objXL.Workbooks.Open(strPathFile) For Each wks In wkb.Worksheets If wkb.wks = wkb.Sheet(2) Then DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTable, strPathFile, blnHasFieldNames End If Next I'm trying to import data from a bunch of Excel files,

Using Conditional Formatting with Icon Sets with six conditions

送分小仙女□ 提交于 2020-04-11 07:44:09
问题 I'm using Conditional Formatting, I've been playing around with Conditional Formatting for a couple of days but I can't get the response I'm looking for. I'm wanting a colored circle to appear in cell based on the marks entered. But the problem is I have six conditions but Excel supports only five I think. Is this possible? 0-20 red color circle 21-39 green color circle 40-54 blue color circle 55-64 yellow color circle 65-79 orange color circle 80-100 pink color circle 回答1: If you are limited

Fastest way to load data from SQL Server to Excel

允我心安 提交于 2020-04-10 19:30:26
问题 I have a table on SQL Server that is relatively huge (approx 300,000 rows). This data is used as a pool of data to validate what users do in an Excel spreadsheet. One way to ensure that users are always using the most up-to-date data is to set up a VBA to auto pull data from SQL server whenever the spreadsheet is open. Code: Private Sub Workbook_Open() Set objMyConn = New ADODB.Connection Set objMyRecordset = New ADODB.Recordset Dim strSQL As String 'Open Connection' objMyConn

Convert range to comma delimited string

Deadly 提交于 2020-04-10 07:26:44
问题 If I had a column like this: Col1 abc def ghi jkl How can I convert it to a string like this?: "abc,def,ghi,jkl" 回答1: You can use the Join() function to join all the elements of a 1 dimensional array with a delimiter. The Transpose() function is used below to form the dimensional array (this approach works on a single column or row). Sub Main() Dim arr arr = Join(Application.Transpose(Range("A2:A5").Value), ",") MsgBox arr End Sub or as an UDF Public Function Merge(r As Range) As String Merge

Convert range to comma delimited string

五迷三道 提交于 2020-04-10 07:26:07
问题 If I had a column like this: Col1 abc def ghi jkl How can I convert it to a string like this?: "abc,def,ghi,jkl" 回答1: You can use the Join() function to join all the elements of a 1 dimensional array with a delimiter. The Transpose() function is used below to form the dimensional array (this approach works on a single column or row). Sub Main() Dim arr arr = Join(Application.Transpose(Range("A2:A5").Value), ",") MsgBox arr End Sub or as an UDF Public Function Merge(r As Range) As String Merge

Upload Excel document to shared folder on Google Drive with Excel VBA?

删除回忆录丶 提交于 2020-04-10 05:21:29
问题 I have found different scripts for Java, C#, and Access VBA for uploading a file to Google Drive. But the only thing I have found with Excel VBA, is a script saving the file in your local Google Drive folder and then wait for the application to sync it. Is it possible to somehow upload the Excel file directly to a folder that has been shared with me? If yes, how? 回答1: I actually managed to do this. First, you need to create credentials. Follow this guide: https://updraftplus.com/support

Upload Excel document to shared folder on Google Drive with Excel VBA?

徘徊边缘 提交于 2020-04-10 05:14:08
问题 I have found different scripts for Java, C#, and Access VBA for uploading a file to Google Drive. But the only thing I have found with Excel VBA, is a script saving the file in your local Google Drive folder and then wait for the application to sync it. Is it possible to somehow upload the Excel file directly to a folder that has been shared with me? If yes, how? 回答1: I actually managed to do this. First, you need to create credentials. Follow this guide: https://updraftplus.com/support

Copy sheet without creating new instances of named ranges?

这一生的挚爱 提交于 2020-04-08 13:21:33
问题 I'm using the following code to copy a sheet. I also have a few named ranges that are scoped to the Workbook. The problem is, when I do the copy, it creates duplicates of all the named ranges with a scope of the new sheet. Everything works of course but I could potentially have 20+ sheets. I don't need 80 named ranges that are mostly duplicates. How can I avoid this? Sub btnCopyTemplate() Dim template As Worksheet Dim newSheet As Worksheet Set template = ActiveWorkbook.Sheets("Template")

Copy sheet without creating new instances of named ranges?

筅森魡賤 提交于 2020-04-08 13:17:39
问题 I'm using the following code to copy a sheet. I also have a few named ranges that are scoped to the Workbook. The problem is, when I do the copy, it creates duplicates of all the named ranges with a scope of the new sheet. Everything works of course but I could potentially have 20+ sheets. I don't need 80 named ranges that are mostly duplicates. How can I avoid this? Sub btnCopyTemplate() Dim template As Worksheet Dim newSheet As Worksheet Set template = ActiveWorkbook.Sheets("Template")