excel-vba

Excel VBA: nested dictionary issue

荒凉一梦 提交于 2020-01-15 08:44:23
问题 I am not able to create a nested dictionary, assign it to a variable, overwrite one of the inner values, and then assign it to another variable without the original variable's value getting changed, which I do not want. For example, see the following code: Option Explicit Sub Button1_Click() Dim d_outer As Scripting.Dictionary Set d_outer = New Scripting.Dictionary Dim d_inner As Scripting.Dictionary Set d_inner = New Scripting.Dictionary Call d_inner.Add("key", "foo") Call d_outer.Add("first

Reopening recently closed instances of Excel

不羁岁月 提交于 2020-01-15 07:49:27
问题 If I use the below code to close all instances of Excel that are currently open what would I need to use to reopen all the instances of Excel that were just closed? I know I'll have to change the below to save a filepath somewhere but just not sure what the actual code should be. Public Sub CloseAllExcel() On Error GoTo handler Dim xl As Excel.Application Dim wb As Excel.Workbook Do While xl Is Nothing Set xl = GetObject(, "Excel.Application") For Each wb In xl.Workbooks wb.Save wb.Close Next

vba line continuation with bracket expression [duplicate]

混江龙づ霸主 提交于 2020-01-15 07:12:29
问题 This question already has an answer here : Line continuation not working in VBA for 2D Array construction (1 answer) Closed last month . varData = [{"Interbank Placement", "LIBOR/IB/COF"; "cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}] I have a code like this. It is too long and I would like to break it into lines. I tried the code below but it still says missing bracket. How can I do this? varData = [{"Interbank Placement", "LIBOR/IB/COF"; _ "cat", "goku"; 4, "cow"; 6,

vba line continuation with bracket expression [duplicate]

為{幸葍}努か 提交于 2020-01-15 07:11:08
问题 This question already has an answer here : Line continuation not working in VBA for 2D Array construction (1 answer) Closed last month . varData = [{"Interbank Placement", "LIBOR/IB/COF"; "cat", "goku"; 4, "cow"; 6, "soccer"; "test", 8; "drinks", "goal"}] I have a code like this. It is too long and I would like to break it into lines. I tried the code below but it still says missing bracket. How can I do this? varData = [{"Interbank Placement", "LIBOR/IB/COF"; _ "cat", "goku"; 4, "cow"; 6,

Copy paste data from one sheet to any other worksheet

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-15 06:59:42
问题 Hi there I have this code which only copy-paste data from sheet 1 one to sheet 2. Sub CopyPasteCumUpdate() Dim rng As Range, inp As Range 'to remove 0 values that may be a result of a formula or direct entry. Set rng = Nothing Set inp = Selection inp.Interior.ColorIndex = 37 On Error Resume Next Set rng = Application.InputBox("Copy to", Type:=8) On Error GoTo 0 If TypeName(rng) <> "Range" Then MsgBox "Cancelled", vbInformation Exit Sub Else rng.Parent.Activate rng.Select inp.Copy Worksheets(

Copy paste data from one sheet to any other worksheet

早过忘川 提交于 2020-01-15 06:59:33
问题 Hi there I have this code which only copy-paste data from sheet 1 one to sheet 2. Sub CopyPasteCumUpdate() Dim rng As Range, inp As Range 'to remove 0 values that may be a result of a formula or direct entry. Set rng = Nothing Set inp = Selection inp.Interior.ColorIndex = 37 On Error Resume Next Set rng = Application.InputBox("Copy to", Type:=8) On Error GoTo 0 If TypeName(rng) <> "Range" Then MsgBox "Cancelled", vbInformation Exit Sub Else rng.Parent.Activate rng.Select inp.Copy Worksheets(

Excel VBA Array not receiving all values from stored procedure recordset - different result than running stored procedure outside of Excel

放肆的年华 提交于 2020-01-15 06:53:56
问题 I have quite a conundrum which I have been trying to troubleshoot. I have a stored procedure in a MySql database, which I call through an Excel VBA application. The VBA application passes the recordset into an Array, and then I use a For Loop to place each of the items in the Array onto a worksheet. Here's the problem: two of the values in the recordset keep coming back blank in Excel. Oddly, the two are in the middle of the Array, not the beginning or end. However, if I call the stored

Userform with Excel 2018 for MacOS

﹥>﹥吖頭↗ 提交于 2020-01-15 06:37:38
问题 I saw that functionality of adding userform into Excel 2018 for MacOS (or since Excel 2016) was not possible unlike with Excel 2011 : when I say "adding userform", I am talking about the "UI" designer which allows to design the buttons, boxes, lists, ... (Actually it seems that adding userform is only available on Windows version of Excel 2018). I am a beginner in VBA scripting even if I have basics of programming in others languages. Could anyone give me a simple example or a tutorial link

VBA 6 : regex not recognizing complicated string

ⅰ亾dé卋堺 提交于 2020-01-15 06:07:21
问题 I have this string "1X214X942,0SX" where each X represents a "non-breaking space" (a whitespace to be exact) with the ASCII code 160, and S represents a space character. I am trying to recognize it with this regex: (\d{1,3}\s(\d{3}\s)*\d{3}(\,\d{1,3})?|\d{1,3}\,\d{1,3}) but it doesn't work, as this whitespace is not recognized and the expression only catches 942,0 . I have tried to see if RegExr can catch the whole string and it can, ( http://gskinner.com/RegExr/?2v8ic) so there's something

Excel VBA: CountIf (value criterion) AND (color criterion)

六眼飞鱼酱① 提交于 2020-01-15 05:48:21
问题 I am trying to count the number of cells in a range that has the same color as a reference cells, IF the corresponding cell in another range has the correct value criterion. For example: If (A1 < 350) and (B1 has the same color as a reference cell), then count 1. Loop over rows 1 to 15 It is essentially the same problem as the question posted here: http://www.mrexcel.com/forum/excel-questions/58582-countif-multiple-criteria-one-being-interior-color.html Unfortunately, it seems that the