excel-vba

Why can't I use the “Any” as a name in VBA?

别说谁变了你拦得住时间么 提交于 2020-06-22 20:34:27
问题 While trying to define an Any() function like python's, I found that I couldn't name anything "Any". Attempting to name a Function, Sub, Const, or variable any will throw a syntax error and the VBA IDE will highlight it. I know any not a particularly great name, but why is it throwing a syntax error? The only reason I could think of was that it might be a reserved keyword, but it's not. 回答1: VBA (Visual Basic for Applications) is not VB.NET, even though they share the same "Visual Basic"

Macro button under customized ribbon tab tries to open old Excel file

末鹿安然 提交于 2020-06-22 13:10:06
问题 I created a custom ribbon tab on my Excel like Excel_app_v1.xlsm , and a button under this ribbon tab is connected to a macro. So when I click this button, the macro does some table importing applications. The first strange thing is that I created this ribbon tab and the button for only this Excel file, but the ribbon tab and the button appear in all other Excel files, even if the original Excel file Excel_app_v1.xlsm is not open. The second problem is that I created a second version of my

How to copy only plain text of cells in Excel?

被刻印的时光 ゝ 提交于 2020-06-22 10:46:45
问题 I am designing an Excel worksheet where the user will click a command button which copies a predetermined range of cells. The user would then paste the contents into a web app using Firefox or IE. The design of the web app is out of my control and currently the text boxes that are used for data input are rich text inputs. This causes the text to look odd and formatted like Excel when the user pastes into them. Is there a way in Excel using VBA to copy only the plain text of the cells that are

How to copy only plain text of cells in Excel?

≡放荡痞女 提交于 2020-06-22 10:46:03
问题 I am designing an Excel worksheet where the user will click a command button which copies a predetermined range of cells. The user would then paste the contents into a web app using Firefox or IE. The design of the web app is out of my control and currently the text boxes that are used for data input are rich text inputs. This causes the text to look odd and formatted like Excel when the user pastes into them. Is there a way in Excel using VBA to copy only the plain text of the cells that are

VBA Excel - IFERROR & VLOOKUP error

给你一囗甜甜゛ 提交于 2020-06-22 04:11:09
问题 I'm trying to create the equivalent of the =IFERROR(VLOOKUP(),-1) formula in excel VBA where the function would look up text in my data table and return the number in the 5th column if the text is in the table and -1 if it isn't. I've tested the above formula in excel and it gives me the desired result the problem is when I go to code it in VBA I keep getting the #VALUE! error if the text is not in the table. The code produces the desired number if the text is in the table. My code is as

How to handle wild characters in Macros?

Deadly 提交于 2020-06-22 02:27:39
问题 I have wrote a piece of code to replace any characters, but it doesn't work fine with * . Can some one guide how I can handle * . Here is the code: nextrow = ActiveCell.Row tocolnbr = ActiveCell.Column Columns(tocolnbr).Select Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False 回答1: Use a ~ tilde as per Office Support. Microsoft Excel uses the tilde (~) as a marker to indicate that the next

How to handle wild characters in Macros?

谁都会走 提交于 2020-06-22 02:25:48
问题 I have wrote a piece of code to replace any characters, but it doesn't work fine with * . Can some one guide how I can handle * . Here is the code: nextrow = ActiveCell.Row tocolnbr = ActiveCell.Column Columns(tocolnbr).Select Selection.Replace What:="'", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False 回答1: Use a ~ tilde as per Office Support. Microsoft Excel uses the tilde (~) as a marker to indicate that the next

Using a variable for row in (row,column) for a range in VBA

大憨熊 提交于 2020-06-21 05:40:06
问题 I have a global variable called processRowBegin that contains the row number for the beginning of a process. I also have a global variable called processRowEnd that contains the row number for the end of a process. What I am trying to do is create a chart for two columns, Columns C and E on the active worksheet, where the range for the selected rows to be plotted is from processRowBegin to processRowEnd. The problem that I am coming across is that I do not know how to use a range with a

Using a variable for row in (row,column) for a range in VBA

假如想象 提交于 2020-06-21 05:40:06
问题 I have a global variable called processRowBegin that contains the row number for the beginning of a process. I also have a global variable called processRowEnd that contains the row number for the end of a process. What I am trying to do is create a chart for two columns, Columns C and E on the active worksheet, where the range for the selected rows to be plotted is from processRowBegin to processRowEnd. The problem that I am coming across is that I do not know how to use a range with a

Retrieve cell value issue with open xml sdk

故事扮演 提交于 2020-06-18 16:56:40
问题 Im having the following issue related with an excel 2007 file called "Libro1.xlsx". On this file i already set to "hello world" the cell A1 in the first sheet with id "rId1" and cell A2 to "500". In the following code you'll see that im accesing every row and cell of this sheet. Im getting as output the content of the cell A2 = 500 but not the content of the A1 cell (im getting "0" as value). Here the code that im using: ' Open the document for editing. Dim ficheroexcel As SpreadsheetDocument