excel-vba

Sum() Across Dynamic Number of Sheets

那年仲夏 提交于 2020-01-01 16:55:47
问题 Hello all and thanks for your help ahead of time, I have an excel sheet that is solely to take the summation of multiple sheets. Best and most simply put, the formula is something like =sum(Sheet1!A1,Sheet2!A1,Sheet3!A1,Sheet4!A1) . There are a few issues that complicate matters though. First off all, I do not know the number or order of the sheets to sum, nor do I know their name. This formula will be copied into ~150 other cells, so I need the summation to be dynamic instead of physically

Sum() Across Dynamic Number of Sheets

最后都变了- 提交于 2020-01-01 16:54:06
问题 Hello all and thanks for your help ahead of time, I have an excel sheet that is solely to take the summation of multiple sheets. Best and most simply put, the formula is something like =sum(Sheet1!A1,Sheet2!A1,Sheet3!A1,Sheet4!A1) . There are a few issues that complicate matters though. First off all, I do not know the number or order of the sheets to sum, nor do I know their name. This formula will be copied into ~150 other cells, so I need the summation to be dynamic instead of physically

Excel VBA runtime error 1004 only with names that begin with 'c'

試著忘記壹切 提交于 2020-01-01 16:45:55
问题 That's right. If I change the 'C' in 'Chart_Series_W_Gain_AAPL' in the following code to any other letter the code works. Otherwise it throws an Error 1004 at the Series.Formula assignment. In fact, if I use any random name that begins with 'c' the code fails but not otherwise. I've tried closing Excel and reopening, but same issue. I came across this because I had been naming my chart series defined names beginning with the name of the chart, but then I decided that was confusing and I

Using excels named range in a sql string in VBScript

半腔热情 提交于 2020-01-01 14:59:15
问题 I have searched on here and google but I still cannot solve my issue. I am trying to use an excel's named range equivalently in my .vbs file. The below works in VBA in excel but I cannot get it to work in a *.vbs file. ThisWorkbook.Sheets(1).Range("A1:B" & Range("B" & Rows.Count).End(xlUp).Row).Name = "DATA" strSql = "SELECT * FROM DATA" So, I have tried different variations of referencing to my named range DATA with no luck. This is what I have now: Set rng = ws.Range("A1:B2") rng = "DATA"

Test whether a property name exists

泄露秘密 提交于 2020-01-01 12:33:06
问题 I'm getting this error: Run-time error '424' object required when I try to run this code: Sub SuperSaveAs() Set objFSO = CreateObject("Scripting.FileSystemObject") Dim pathName As String Dim myFileName As String If (ActiveDocument.CustomDocumentProperties("_CheckOutSrcUrl").Value = True) Then pathName = ActiveDocument.CustomDocumentProperties("_CheckOutSrcUrl").Value myFileName = pathName + ActiveWorkbook.Name ActiveWorkbook.SaveAs Filename:= _ myFileName _ , FileFormat:

Microsoft.Jet.OLEDB.4.0 - Provider can not be found or it may not be installed

戏子无情 提交于 2020-01-01 09:54:06
问题 I have created an Excel Macro in which I have used Microsoft.Jet.OLEDB.4.0 to fire query on Excel work sheets. It's working perfect on my machine but my client is facing issue with it. (see the attached screen print) Here are details for my Connection Object: Dim cn Set cn = CreateObject("ADODB.Connection") With cn .Provider = "Microsoft.Jet.OLEDB.4.0" .ConnectionString = "Data Source=" & ThisWorkbook.FullName & "; Extended Properties=Excel 8.0" .Open End With Please Note: It is must for me

EXcel VBA : Excel Macro to create table in a PowerPoint

无人久伴 提交于 2020-01-01 09:53:13
问题 My requirement is I have a Excel which contains some data. I would like to select some data from the excel and open a PowerPoint file and Create Table in PowerPoint and populate the data in to it Right now I have succeeded in collecting the data from excel opening a PowerPoint file through Excel VBA Code. Code for Opening the PowerPoint from Excel. Set objPPT = CreateObject("Powerpoint.application") objPPT.Visible = True Dim file As String file = "C:\Heavyhitters_new.ppt" Set pptApp =

Excel VBA - format a whole column excluding the heading line

与世无争的帅哥 提交于 2020-01-01 09:40:14
问题 I want to format a column but to exclude the first row as this is the header: My current Code is: Sheets("Sheet1").Columns(3).NumberFormat = "#,##0" Thank you. 回答1: Unless the header is a number you shouldn't need to do this, I don't think. The number format won't affect text (at least not much). But here's a way: With ThisWorkbook.Sheets("Sheet1") .Columns(3).Resize(.Rows.Count - 1, 1).Offset(1, 0).NumberFormat = "#,##0" End With 回答2: Alternatively Sheets("Sheet1").Range(cells(2,3), cells(2

Excel ActiveX Listbox not enabled on file open

心不动则不痛 提交于 2020-01-01 08:38:42
问题 I am trying to figure out a bizarre situation. I have a workbook with many sheets. On one sheet, I have one ActiveX listbox (CTOverview.Listbox1). On a second sheet, I have a total of three listboxes (CTSelected.Listbox1 thru Listbox3). I am using a query to populate Listbox1 on both sheets with the same data. The code for this is below: strSQL = "Select Distinct [Region] From [UniqueCTList$] Order by [Region]" closeRS OpenDB ' initialize listboxes CTSelect.ListBox1.Clear CTSelect.ListBox2

Checking if a value is a member of a list

怎甘沉沦 提交于 2020-01-01 08:33:05
问题 I have to check a piece of user input against a list of items; if the input is in the list of items, then direct the flow one way. If not, direct the flow to another. This list is NOT visible on the worksheet itself; it has to be obfuscated under code. I have thought of two strategies to do this: Declare as an enum and check if input is part of this enum , although I'm not sure on the syntax for this - do I need to initialise the enum every time I want to use it? Declare as an array and check