excel-vba

Merging excel spreadsheets into one spreadsheet

浪尽此生 提交于 2020-01-10 05:05:07
问题 Okay, I tried to look for similar questions but I didn't understand much of what was being discussed since it's the first time I'm looking at Excel's VBA editor. In simple terms, I have 2 spreadsheets: "Sheet1" and "Sheet2" Sheet 1: A B 1 Header1 Header2 2 Text1 Info1 3 Text2 Info2 Sheet 2: A B 1 Header1 Header2 2 Text3 Info3 3 Text4 Info4 And I would like to have a macro to merge the two sheets into a new sheet (Sheet3), like this: A B 1 Header1 Header2 2 Text1 Info1 3 Text2 Info2 4 Text3

Batch Convert TXT to XLS Using VBA

穿精又带淫゛_ 提交于 2020-01-10 04:30:17
问题 I am trying to convert a directory full of .txt files to .xls using VBA. I am using the following code: Sub TXTconvertXLS() 'Variables Dim wb As Workbook Dim strFile As String Dim strDir As String 'Directories strDir = "\\xx\xx\xx\xx\Desktop\Test\Test1\" strFile = Dir(strDir & "*.txt") 'Loop Do While strFile <> "" Set wb = Workbooks.Open(strDir & strFile) With wb .SaveAs Replace(wb.FullName, ".txt", ".xls"), 50 .Close True End With Set wb = Nothing Loop End Sub The issue is: when I run it, it

Excel's VBA ActiveWorkbook is “Nothing” when “Enable Editing” from ProtectedView

末鹿安然 提交于 2020-01-10 04:02:18
问题 I have a VBA macro which is called from a spreadsheet function (user defined function, UDF). When the spreadsheet is downloaded from the internet and the user has set "Trust Center" settings accordingly, the spreadsheet will open in so the called "Protected View". The function will not be called. A button "Enable Editing" is shown. If the button is pressed, the spreadsheet is "trusted" and reopened normally, starting calculation, and hence calling the user defined function. However, in that

Excel headers/footers won't change via VBA unless blank

守給你的承諾、 提交于 2020-01-10 03:50:14
问题 Disclaimer: It's been a few years since I worked (a lot) with VBA, so this might be an issue caused by confusing myself with what is essentially a very different language from what I usually deal with. So; I've got a workbook (Excel 2010) with multiple sheets (20+), most of whom are multi-page. To make things easier when printing everything, I want to add some sheet-specific headers with amongst others the name of the sheet, number of pages and so on. I've written a tiny function that should

Adding hyperlinks to excel email body text

守給你的承諾、 提交于 2020-01-10 03:45:26
问题 I am trying to generate emails from excel but want to add hyperlinks to the email body text. I want the hyperlinks to show as text and not the file paths. How would I go about doing this? I am using the below code. strBody = "Hello " & Range("QuoteFirstName").Value & "," & _ vbNewLine & _ vbNewLine & _ "It was good to speak with you earlier today/yesterday." & _ vbNewLine & _ vbNewLine & _ "[Any personal message]" & _ vbNewLine & _ vbNewLine On Error Resume Next With OutMail .To = StrTo .CC =

Automation error when getting ReadyState of InternetExplorer object

前提是你 提交于 2020-01-10 02:57:39
问题 I get two different errors on the same line. Sometimes this one: Automation error: object invoked has disconnected from its clients and sometimes: the interface is unknown Minimal code to reproduce error: Sub mcve() Dim ie As Object Dim www As String Set ie = New InternetExplorerMedium www = "http://www.stackoverflow.com" ie.navigate www ie.Visible = False While ie.ReadyState <> 4 ' <~~~~~~~~~~~~~~~~~~~~~~~~ Error occurs here DoEvents Wend End Sub This requires a reference: Tools > References

How to Create a Pivot Table in VBA

自作多情 提交于 2020-01-10 02:08:19
问题 I'm trying to create a Pivot table, but getting Invalid Procedure Call or Argument . ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="rng", Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:="rngB", TableName:="pvtReportA_B", DefaultVersion:=xlPivotTableVersion14 rng (The source) is a range consisting of about 20 columns and a few thousand rows. rngB (The destination) is a single cell in a different worksheet Can anyone advise where I am going wrong? EDIT

How to Create a Pivot Table in VBA

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 02:08:18
问题 I'm trying to create a Pivot table, but getting Invalid Procedure Call or Argument . ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="rng", Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:="rngB", TableName:="pvtReportA_B", DefaultVersion:=xlPivotTableVersion14 rng (The source) is a range consisting of about 20 columns and a few thousand rows. rngB (The destination) is a single cell in a different worksheet Can anyone advise where I am going wrong? EDIT

Excel VBA script to find 404 errors in a list of URLs?

China☆狼群 提交于 2020-01-09 23:52:16
问题 So, I have this spreadsheet with a list of about 5000 URLs. (All pages on our corporate intranet.) We know some of the links are broken, but don't know of a good way to determine which without clicking all 5000 links. Normally this would be a simple matter: Create a web page with links to the 5000 pages, and then check the links with a tool like Xenu Link Sleuth. But that won't work in this case because many of the links are being redirected, and the redirect code spoofs HTTP.response 200,

How do I call WCF client from Excel 2003 VBA?

元气小坏坏 提交于 2020-01-09 19:51:06
问题 As the question asked, how do I call WCF client from Excel 2003 VBA? I saw there is a place where I can call web service, but I have searched through Google, all the results I get is not possible to call a WCF client from VBA. I would like to know sort of what method to use before I do anything with my code, don't want to waste the time and discover later that it is not possible to do that. 回答1: You might want to look at using the WCF Service Moniker which lets you invoke a WCF Service from