vba

Replace reference to worksheet in a formula via macro

こ雲淡風輕ζ 提交于 2021-02-08 11:13:08
问题 I have a button which produces a new worksheet. I pass the name of the active worksheet (the origin of the clicked button). Clicking the button on a worksheet named "A", produces a sheet "Print" based on the active worksheet "A". The formula of the cells in the "Print" sheet reference "A" (e.g. 'A'!B1). I have a worksheet named "B". When I click the button it should replace the "A" in the formula of all cells in "Print" worksheet. It seems that wildcard in replace doesn't work. For Each cell

Selectively copy and paste rows with given criteria

拟墨画扇 提交于 2021-02-08 11:09:58
问题 I am trying to select rows in a table based on the word "Yes" being present in column J. I have a table going from column A to J, and I want to select the rows where there is a "Yes" in column J and paste only those rows into a new sheet. Once selected, I need to copy these rows to a new sheet or word document. I have tried a range of forumulas, this is for Windows MS Excel software, using a VBA Macro. I am using the following VBA, but having issues: Sub Macro1() Dim rngJ As Range Dim cell As

Bolding Text with VBA

南笙酒味 提交于 2021-02-08 10:37:23
问题 Here's the cell formula I'm using: ="Charge: "&(UPPER(AG343))&" "&" Charging Staff: "&(AH343)&" "&" Charging Staff: "&(AI343)&" "&" CAP_ID: "&(AJ343) Is there a way in VBA to recognize that a value is being pulled into Cell "A" from a reference to Cell "B" and to make the text representation of the reference from Cell "B" in Cell "A" bold? I've seen posts on this subject on the limitations of Excel functions to manipulate text. I don't understand why I can use the UPPER function on the

Mirror a single table to multiple sheets in excel using vba

情到浓时终转凉″ 提交于 2021-02-08 10:37:22
问题 I have one table in the database sheet in which i would want to paste link to another sheet. However i realised that it is not possible using excel and vba. Is there any ways to reference these tables automatically? Equating the cell ranges is one way that i know of but it is extremely tedious because i have over 50 tables of such. Hard coding these equations are a trouble.This is a basic code I have done to copy paste a table . Sub table() ActiveSheet.ListObjects("Table1").Range.Copy 'This

Mirror a single table to multiple sheets in excel using vba

倾然丶 夕夏残阳落幕 提交于 2021-02-08 10:36:21
问题 I have one table in the database sheet in which i would want to paste link to another sheet. However i realised that it is not possible using excel and vba. Is there any ways to reference these tables automatically? Equating the cell ranges is one way that i know of but it is extremely tedious because i have over 50 tables of such. Hard coding these equations are a trouble.This is a basic code I have done to copy paste a table . Sub table() ActiveSheet.ListObjects("Table1").Range.Copy 'This

Bolding Text with VBA

。_饼干妹妹 提交于 2021-02-08 10:36:03
问题 Here's the cell formula I'm using: ="Charge: "&(UPPER(AG343))&" "&" Charging Staff: "&(AH343)&" "&" Charging Staff: "&(AI343)&" "&" CAP_ID: "&(AJ343) Is there a way in VBA to recognize that a value is being pulled into Cell "A" from a reference to Cell "B" and to make the text representation of the reference from Cell "B" in Cell "A" bold? I've seen posts on this subject on the limitations of Excel functions to manipulate text. I don't understand why I can use the UPPER function on the

Saving Word document as PDF

天涯浪子 提交于 2021-02-08 10:35:56
问题 This is related to converting a Word document to PDF format. I get an error in my Excel VBA code. Run-time error "5": Invalid procedure call or argument Saving into a Word document works objWord.ActiveDocument.SaveAs PathName & NewFileName & ".docx" The below runs but it creates a PDF document which is very big in size. objWord.ActiveDocument.SaveAs2 Filename:=PathName & NewFileName & ".pdf", _ FileFormat:=wdFormatPDF I recorded a macro in Word to save the file as PDF and modified the

DoCmd.TransferSpreadsheet Export: Let user choose save destination?

旧城冷巷雨未停 提交于 2021-02-08 10:25:47
问题 I successfully run TransferSpreadsheet to export an Access query to an Excel file at a specified location: Private Sub cmdExportQuery_Click() DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "trndOTQry", _ "\\company.com\root\share\public\D2S\D2S\D2S_Scorecard\Trend OT.xls" End Sub Given that this is a shared file, I want a dialog to open that allows the user to select whatever save destination he chooses. I found this link with a good solution that references this article. When

Array processing VBA

烈酒焚心 提交于 2021-02-08 10:22:26
问题 i'm prototyping a solution for a tidious task using vba because my company's security only allows this method, can't use python nor anything else. i have a table of 5K+ rows and about 15 columns, and i want to process it removing specific columns based on a search criteria. so here's my code so far Sub RstCr() Dim Sh As Worksheet Dim Ar() As Variant Dim Arr As Variant Dim i As Integer Dim j As Integer Dim k As Integer Dim p As Integer Set Sh = Sheets("Sheet1") Sh.Cells(1, 1).CurrentRegion

Dynamically Create collection of Collections VBA

爱⌒轻易说出口 提交于 2021-02-08 10:21:08
问题 I'm trying to dynamically create a collection with collections nested within. So far, I've been able to create a nested collection by typing everything (see below). However, I have a ( horrible ) spreadsheet that has a repeating set of 17 questions hundreds of times in one column, and the answers in the next column. I'm trying to get the answer to each question as an item, and the question itself as the index. The unique set of the 17 questions will be a collection within a collection of the