Posts

Showing posts with the label excel-vba

Run Time Error on Active formula in Excel Macro code

Run Time Error on Active formula in Excel Macro code I want to use the value of cell A5 of Sheet 2 to my active formula in macro in Sheet 1. However, I'm getting an Error 1004 (application defined or object defined error). If using a static value, for instance 100, instead of 'Sheet 2'!A5 , it is working. 'Sheet 2'!A5 Below is my code: ActiveCell.FormulaR1C1 = "=if('Sheet 2'!RC>'Sheet 2'!A5,""PASS"", ""FAIL"")" 1 Answer 1 You cannot mix-and-match xlA1 cell references with xlR1C1 cell references. A5 is R5C1 in xlR1C1 syntax. ActiveCell.FormulaR1C1 = "=if('Sheet 2'!RC>'Sheet 2'!R5C1,""PASS"", ""FAIL"")" Now in this formula, the RC is a relative row/relative column reference to the same cell on 'Sheet 2' that the active cell on the active ...

How can I loop through my “getElementById” VBA for multiple websites?

Image
How can I loop through my “getElementById” VBA for multiple websites? I'm part of a non-profit that sends letters to encourage hundreds of people in prison. They are often transferred unexpectedly, with no time to give notice of address change. However, each person's location while incarcerated is kept up-to-date and publicly accessible on the state government's website. I am trying to write VBA that goes through my "contact" list and visits each state government's prisoner location website (based on each prisoner's ID), then extracts each person's location from the website, places that in a column ($C) for that purpose which corresponds to the row for that specific person's name & ID. That way I could run a check automatically to confirm each one is still at the same location before I do an Excel mailmerge to print envelope labels with their addresses. Here's what I'm using to get the correct value (I've just been testing with a ...

Excel VBA running a macro across 50 sheets

Excel VBA running a macro across 50 sheets In excel VBA, I am trying to run a simple autofilter across 50 sheets, however, it only runs it across one sheet. Can anyone help? The code is below: Sub Macro2() ' ' Macro2 Macro ' Dim wb As Workbook For Each wb In Application.Workbooks Range(Selection, Selection.End(xlToRight)).Select Selection.AutoFilter Selection.End(xlToLeft).Select Range("G1").Select ActiveSheet.Range("$A$1:$AC$91").AutoFilter Field:=7, Criteria1:=Array("11" _ , "21", "22", "23", "31-33", "42", "44-45", "48-49", "51", "52", "53", "54", "55", "56", "61" _ , "62", "71", "72", "81"), Operator:=xlFilterValues Selection.End(xlToLeft).Select Next wb End Sub You can just paste your code...

VBA, i want to import a txt file to excel and I want it to be reorganized to a specific format [on hold]

VBA, i want to import a txt file to excel and I want it to be reorganized to a specific format [on hold] I have a txt file in the format below ,I want to import it to excel and I want it to be reorganized using Vba code. Timestamp : ##/##/## ##:##:## ## PM File # : #### Type : LLLLLL Range : #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) Stat : N/A ________________________________________________________________________ Timestamp : ##/##/## ##:##:## ## AM File # : #### Type : LLLLLL Range : #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) #####:#####-#####/#(#-###) Stat : N/A ________________________________________________________________________ . . n Repeated "n" times , "n" changes daily and I would like to import it to excel reorgan...

Excel - Turn off the window that asks you to change links to a workbook

Excel - Turn off the window that asks you to change links to a workbook I generated links to some 100 workbooks but not all of them exist. This is fine because if they do not exist it usually means I don't need it. The links are generated based on string concatenation, and the final step is to paste by value to a cell. A sample of the link may look like this "='P:TEMP[wb1.xlsx]sheet1'!$D$1 "='P:TEMP[wb1.xlsx]sheet1'!$D$1 What I need now, is to remove the first quotation mark to bring the link "alive". I wrote a macro that does the find and replace in the row Sub BringAlive() Rows("18").Select Selection.Replace What:="""", Replacement:="", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End Sub The only issue with this is that when a workbook doesn't exist, a window pops out asking me to find the workbook. I need to hit ESC many many times until the ...