excel-vba

Using the Find Function in VBA

痴心易碎 提交于 2020-07-08 20:35:21
问题 1 2 3 4 . . So I have a sequence of numbers running from 1-20. I have the number "1" on top selected and I would like to search the entire column and find the number "9". The code works when I don't name the range "rng"; it finds the number and selects. But the code stops working when I name the range of number. What's wrong with the range function? could it be that if I define Dim rng as Range that when I later define the "Set rng=" I cannot have the ".Select" or ".Copy" extension on the end

Using the Find Function in VBA

一笑奈何 提交于 2020-07-08 20:33:27
问题 1 2 3 4 . . So I have a sequence of numbers running from 1-20. I have the number "1" on top selected and I would like to search the entire column and find the number "9". The code works when I don't name the range "rng"; it finds the number and selects. But the code stops working when I name the range of number. What's wrong with the range function? could it be that if I define Dim rng as Range that when I later define the "Set rng=" I cannot have the ".Select" or ".Copy" extension on the end

Excel VBA - Replace a text inside cell's formula

一个人想着一个人 提交于 2020-07-08 11:55:10
问题 I have faced a strange thing in Excel VBA coding. I have a sheet full of formulas, each refers to the cells in other sheets. This is a sample formula in cell A1, for example: =IF('General Inputs & Summary'!B6="","",'General Inputs & Summary'!B6) I want to dynamically change the old tab names in formulas, with new tab names. When I try this code: oldStr = "'General Inputs & Summary'" newStr = "'test'" Range("A1").Formula = Replace(Range("A1").Formula, oldStr, newStr) it results in: =IF(test!B6

Excel VBA, I get a prompt “Windows security” when accessing an URL

二次信任 提交于 2020-07-08 10:38:50
问题 I Have an Excel file that access an URL HTTPS. The URL as a basic authentication with username and password. This macro is running every morning and night. It need it to be AUTOMATIC. I have the username and password. The problem is that each time I run the macro, it Prompt me for the "Windows security". The user name and password is already fill up because I did add this connection in my credential. The "windows security" just wait for a user to click enter. This macro should run automaticly

Excel VBA, I get a prompt “Windows security” when accessing an URL

久未见 提交于 2020-07-08 10:37:33
问题 I Have an Excel file that access an URL HTTPS. The URL as a basic authentication with username and password. This macro is running every morning and night. It need it to be AUTOMATIC. I have the username and password. The problem is that each time I run the macro, it Prompt me for the "Windows security". The user name and password is already fill up because I did add this connection in my credential. The "windows security" just wait for a user to click enter. This macro should run automaticly

How to rename the selected shape in Excel

风格不统一 提交于 2020-07-08 03:18:11
问题 If I select a shape, such as a chart or text box, how can I rename it in VBA? I have a nice little sub and form in PowerPoint that does this: Sub ShapeName() If Not ActiveWindow.Selection Is Nothing Then If ActiveWindow.Selection.Type = ppSelectionShapes Then NameForm.NameBox.Text = ActiveWindow.Selection.ShapeRange.Name NameForm.Show If Not NameForm.bCancel Then ActiveWindow.Selection.ShapeRange.Name = NameForm.NameBox.Text End If End If End If End Sub How can I achieve the same in Excel?

How to rename the selected shape in Excel

╄→гoц情女王★ 提交于 2020-07-08 03:17:41
问题 If I select a shape, such as a chart or text box, how can I rename it in VBA? I have a nice little sub and form in PowerPoint that does this: Sub ShapeName() If Not ActiveWindow.Selection Is Nothing Then If ActiveWindow.Selection.Type = ppSelectionShapes Then NameForm.NameBox.Text = ActiveWindow.Selection.ShapeRange.Name NameForm.Show If Not NameForm.bCancel Then ActiveWindow.Selection.ShapeRange.Name = NameForm.NameBox.Text End If End If End If End Sub How can I achieve the same in Excel?

VBA to open Excel or/and Word Files

浪子不回头ぞ 提交于 2020-07-08 03:07:01
问题 I'm trying to setup a command button in a user form to allow the user to open either an Excel and/or a Word Document one at a time or both at the same time. But so far I'm able only to select and open Excel but not Word files with the following code: Sub OpeningExcelFile() Dim Finfo As String Dim FilterIndex As Integer Dim Title As String Dim Filename As Variant Dim wb As Workbook 'Setup the list of file filters Finfo = "Excel Files (*.xlsx),*xlsx," & _ "Macro-Enable Worksheet (*.xlsm),*xlsm,

VBA to open Excel or/and Word Files

余生颓废 提交于 2020-07-08 03:06:27
问题 I'm trying to setup a command button in a user form to allow the user to open either an Excel and/or a Word Document one at a time or both at the same time. But so far I'm able only to select and open Excel but not Word files with the following code: Sub OpeningExcelFile() Dim Finfo As String Dim FilterIndex As Integer Dim Title As String Dim Filename As Variant Dim wb As Workbook 'Setup the list of file filters Finfo = "Excel Files (*.xlsx),*xlsx," & _ "Macro-Enable Worksheet (*.xlsm),*xlsm,

Copy userform to another workbook

纵然是瞬间 提交于 2020-07-07 10:41:42
问题 I've had a look for an answer to this question but can't find anything that matches exactly what I'm looking for, if someone has the answer or can point me in the direction of a question which answers this, it would be much appreciated. I've been talked with building a solution to enter data into a workbook and have successfully built it, however the workbook it need to be added to is a very active tool and is constantly being updated with new/changed data, so I have had to build it in a copy