excel-vba

Copy sheet without creating new instances of named ranges?

非 Y 不嫁゛ 提交于 2020-04-08 13:15:01
问题 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:14:48
问题 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:14:37
问题 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")

Rename Excel Sheet with VBA Macro

空扰寡人 提交于 2020-04-08 02:03:12
问题 I want to ask about rename the excel sheet, i want to rename the sheet with new name : older name + _v1. So if my current sheet name is test , then I want the new name test_v1 . I only know the standard vba for rename excel sheet which is renaming excel sheet by the sheet content. Sub Test() Dim WS As Worksheet For Each WS In Sheets WS.Name = WS.Range("A5") Next WS End Sub 回答1: This should do it: WS.Name = WS.Name & "_v1" 回答2: The "no frills" options are as follows: ActiveSheet.Name = "New

How to change case of matching letter with a VBA regex Replace?

孤街醉人 提交于 2020-04-07 08:53:11
问题 I have a column of lists of codes like the following. 2.A.B, 1.C.D, A.21.C.D, 1.C.D.11.C.D 6.A.A.5.F.A, 2.B.C.H.1 8.ABC.B, A.B.C.D 12.E.A, 3.NO.T A.3.B.C.x, 1.N.N.9.J.K I want to find all instances of two single upper-case letters separated by a period, but only those that follow a number less than 6. I want to remove the period between the letters and convert the second letter to lower case. Desired output: 2.Ab, 1.Cd, A.21.C.D, 1.Cd.11.C.D 6.A.A.5.Fa, 2.Bc.H.1 8.ABC.B, A.B.C.D 12.E.A, 3.NO

“TypeOf…Is Child” from Parent causes broken Excel file

我怕爱的太早我们不能终老 提交于 2020-04-07 03:38:07
问题 I've been tracking down this issue for several days, so I thought I'd post it here to help others with the same problem, as well as learn more about the cause. I've simplified the problem code to the two class modules at the end of this post. Basically, the simplified scenario is this: Two class modules, Parent and Child, where Child implements Parent. Somewhere in Parent is the line TypeOf Me Is Child , where Me could be any Object. From my understanding, when the TypeOf...Is line is

Excel crash when trying to Autocomplete an ActiveX ComboBox

萝らか妹 提交于 2020-04-07 02:52:21
问题 I have an ActiveX Combobox control on a worksheet and this is the _Change event code Private Sub ComboBox1_Change() Me.ComboBox1.ListFillRange = "ItemSearch" Me.ComboBox1.DropDown End Sub When I use keyboard up/down key to move through the list it automatically quits Excel. Does anyone know the solution to this problem? I basically want a dynamic ComboBox. 回答1: You are forcing Combobox's possible values to update when you change the selected option, that is why it's crashing. You can try to

Search for sheets' name if matched condition then copy paste value with format?

自古美人都是妖i 提交于 2020-04-05 06:21:37
问题 Update: I was able to solve this problem. I just remembered VBA use * and ? to present the string 'If Sheet.name Like "* CopyA "' I would like to make a copy special value with original format of the sources of all sheets contains the word: "CopyA" for example "Apple CopyA","Mango CopyA" I can use the macro record to see how VBA create sheet and copy special like similar example below. I am having trouble in the searching for sheet name - All examples I found either I must know exact name

Search for sheets' name if matched condition then copy paste value with format?

六月ゝ 毕业季﹏ 提交于 2020-04-05 06:19:52
问题 Update: I was able to solve this problem. I just remembered VBA use * and ? to present the string 'If Sheet.name Like "* CopyA "' I would like to make a copy special value with original format of the sources of all sheets contains the word: "CopyA" for example "Apple CopyA","Mango CopyA" I can use the macro record to see how VBA create sheet and copy special like similar example below. I am having trouble in the searching for sheet name - All examples I found either I must know exact name

Web.Contents() update URL in a for loop VBA

别说谁变了你拦得住时间么 提交于 2020-03-26 03:21:11
问题 I am struggling to import table data from a stock market website. They keep the data of a stock from corresponding years in such fashion: https ://........./stockName1/...../1 https ://........./stockName1/...../2 https ://........./stockName1/...../3 https ://........./stockName1/...../4 ...and so on I'd like to automate the process of importing this data, because there are 400 stocks on the list and each has about 10+ web pages of content. This is the code i got from recording the macro: