excel-2013

Use string variable to set object variable in VBA? (Excel 2013)

夙愿已清 提交于 2019-12-06 04:13:10
I have a number of ActiveX controls/buttons on a page, and I would like to modify several of the parameters of the buttons (in a loop function). I am fine with writing the loop function to achieve this, but cannot find a way to refer to the object using a string variable. I have set up an object variable (as per below), and a string variable to be used to change the reference for the object variable - but can't find a way to get it to work. This is the code that does NOT work: Private Sub TrialCode_Click() Dim ButtonObj As Object Dim ButtonCaption As String Dim ButtonString As String

Filter all unique items like Google Docs

半城伤御伤魂 提交于 2019-12-06 04:05:56
Is there a quick/easy way to filter all unique items in an Excel 2013 column similar to the Google Docs "Unique" function? Use the Unique records only feature in Advanced Filter. Under the DATA tab there is this: "Remove Duplicates". It'll do what you want. Brian M There isn't an equivalent to =unique() in Excel, and I hate having to work without it. Without =unique() trying to find all of the unique values in a large array of data is impossible. Take a dozen columns of a hundred+ entries and see what the unique values are across the whole mess and pop them nicely into a new columns. I can't

How to reference an old version of the VBA library?

ぐ巨炮叔叔 提交于 2019-12-05 19:44:32
I'm using Excel 2013. The VBA reference is part of Excel ( built-in ) so I can't remove it. Is it possible to reference another version of the VBA library? The reason I want to know other than curiosity is to look at the object browser of the older versions to see if it lists some currently-hidden/obsolete properties/methods such as Excel.DialogSheet . The Workbook.SheetActivate event has a Sh parameter of type Object. One of the possible sheet types is Excel.DialogSheet which should be checked with the TypeOf operator . When I try to add another VBA reference I get the message: Name conflicts

Building a Macro to Download Data off a Website into Excel

空扰寡人 提交于 2019-12-05 07:52:44
问题 I would like to build a macro in Excel using VBA to download historical data off the following website: http://quickstats.nass.usda.gov/results/320F1D82-1064-30F1-809E-F77E509EC508 I first create a command button as usual. I then thought this may be able to be easily solved using a macro recorder. However when I select Data -> Get External Data -> From Web and then type in the above address I am unable to select the table as a whole as the data. So, I am unsure how to do this task otherwise

Calculating Standard Deviation with If in Excel

二次信任 提交于 2019-12-05 07:47:21
I have a dataset with two columns. One label and one number. Using sumif and countif , I managed to calculate the average of each label in groups. Now, I am trying to do the same with Standard Deviation but I have a problem: =STDEV.P(IF($A$2:$A$625129=F4,$B$2:$B$625129)) This is the formula I use, where A column is the column with the labels, B with the numbers and F4 is one of the label groups. The result is 0. I do the same for every label group and all of them are 0. Any idea what is wrong in the formula? Edit: After the comment, I tried to apply the formula as an array one and it almost

Use VBA to paste values from one table to another

淺唱寂寞╮ 提交于 2019-12-04 21:21:22
I have the following VBA code that takes a single row from Sheet Tabled data, copies the data, then pastes the data into the next available row in Sheet Running list. However the original row has formulas and I need the values to paste, not the formulas. I've seen numerous ways to do it with Range.PasteSpecial but this code didn't use Range and I'm not sure how to incorporate it. Note: I modified this code from here: http://msdn.microsoft.com/en-us/library/office/ff837760(v=office.15).aspx . It originally had an If statement to match content in a cell then paste it in a certain sheet according

Excel 2013 VBA Sheets.Add doesn't return new sheet?

梦想与她 提交于 2019-12-04 18:41:08
So my code was working fine, until IT upgraded me to Excel 2013 and the SDI interface. Now it looks like the Sheets.Add function doesn't return the proper worksheet. The template is added to the correct workbook (Template1) but when I use the returned worksheet, it's referencing a sheet from the active workbook, before all the VBA code ran. Public Function Worksheet_AddTemplate(TargetBook As Excel.Workbook, _ TemplateFile as String) As Excel.Worksheet Dim ws As Excel.Worksheet Debug.Print TargetBook.Name 'Output-->Template1 Set ws = TargetBook.Sheets.Add( _ After:=TargetBook.Sheets(TargetBook

Self Adjusting Userform Size

心不动则不痛 提交于 2019-12-04 14:44:26
问题 I have been googling for the past several hours and I have found all kinds of neat ways to adjust a Userform to fit the size of different monitors or to add a dragbar in the corner to be able to adjust the size at will manually. Sadly however this is not what I had in mind. I am unsure if what I want is even doable but if anyone can this community can do it. The goal for me is have a Userform with lots of information on it to auto adjust in size to show all of the visible controls but no

How to set 'Fit all columns on one page' in print tab

风格不统一 提交于 2019-12-04 00:21:41
The only thing I would want is to always set the 'Fit all columns on one page' setting when users open the Print tab in Excel. And no, they don't want to do it themselves. What a surprise :) Here is a screenshot of where that is in Excel 2013: Tried to look for some VBA code like the following but without success. With Sheets("Print Letter").PageSetup .FitToPagesWide = 1 .FitToPagesTall = 1 End With Try setting the .FitToPagesTall to False to be able to manually set the .FitToPagesWide property. MSDN link If this property is False, Microsoft Excel scales the worksheet according to the

Self Adjusting Userform Size

旧街凉风 提交于 2019-12-03 21:46:50
I have been googling for the past several hours and I have found all kinds of neat ways to adjust a Userform to fit the size of different monitors or to add a dragbar in the corner to be able to adjust the size at will manually. Sadly however this is not what I had in mind. I am unsure if what I want is even doable but if anyone can this community can do it. The goal for me is have a Userform with lots of information on it to auto adjust in size to show all of the visible controls but no extra dead space. There would be 3 Combo boxes always visible at the top but below those are 26 labels and