Posts

Showing posts with the label excel-vba

Conditional SUM within VBA

Image
Conditional SUM within VBA Large excel data which looks like this: Now I have to create a macro for my data to filter. The filtration process is as follows: First select the operator = mum and then select price as 1 and get sum of count column and then 2 and get sum of count column and so on.... then select operator = delhi and similarly select price as 1 and get sum of count column and then 2 and get sum of count column and so on Record Macro then generalise and optimise. – PatricK Jul 2 at 6:09 1 Answer 1 For mum , =sumifs(c:c, d:d, 1, f:f, "mum") =sumifs(c:c, d:d, 2, f:f, "mum") =sumifs(c:c, d:d, 3, f:f, "mum") ... For dehli , =sumifs(c:c, d:d, 1, f:f, "dehli") =sumifs(c:c, d:d, 2, f:f, "dehli") =sumif...

VBA: Copy row from SourceSheet and paste into DestSheet using dynamic rows

VBA: Copy row from SourceSheet and paste into DestSheet using dynamic rows I'd like to copy area from another workbook. SOURCE: The area starts from J15 to last row of J column. I'm having trouble with the syntax. DESTINATION: The area where the paste is the same area as in the Sourceworkbook, but K Column (K15 to last row of J column) The problem is the with statement. I keep getting this error: https://pasteboard.co/HsxMzPZ.jpg Picture of the sourcesheet for clarification https://pasteboard.co/Hs8gDsF.jpg Public Sub Subledger_Makro() Dim Subwb As Workbook Dim Subsht As Worksheet Dim Sourcewb As Workbook Dim SourceSht As Worksheet Set Subwb = ActiveWorkbook Set Subsht = Subwb.Sheets("SAPBW_DOWNLOAD") SourceFile = Application.GetOpenFilename(, , "Open yesterdays Subledger Report") Set Sourcewb = Workbooks.Open(SourceFile) Set SourceSht = Sourcewb.Sheets("SAPBW_DOWNLOAD") 'Copies the previous day Subledger (SourceSht) report J-Column to new the ...

Run macro at specific time when check box is checked(manual calculation)

Run macro at specific time when check box is checked(manual calculation) I'm trying to run a macro in excel at a specific time if check box is checked. It is working as it should, only problem is that it works only when workbook is set to automatic calculations and I need workbook to be set to manual calculations. Here is a VBA code I'm using in that file: sheet1: Private Sub Worksheet_Calculate() Dim time_dt As Date time_dt = Cells(1, 7) If Range("C1").Value = "YES" Then Application.OnTime TimeValue(time_dt), "FillFirstColumn" End If End Sub and here is a Module 1 code: Sub FillFirstColumn() Range("A1:A20").Value = "YES" End Sub When I click on check box, cell D1 is changing from FALSE to TRUE. In a cell C1 I have this formula =IF(D1=TRUE,"YES","NO"). And C1 is not recalculating unless a workbook is set to automatic. Based on advice from a comment below I've added this VBA code to sheet1: Private Sub Che...

Web scrapping of masked URL using VBA

Image
Web scrapping of masked URL using VBA I want to scrape some stock data from a website https://dps.psx.com.pk/ using VBA in Excel, but the problem is the URL of this website does not change. When I click on market summary as highlighted in the below image that will return the whole market summary, I just need to scrape data in Excel using VBA as highlighted in the following image: Did you look at the requests being made when you search for "EFOODS"? – antfuentes87 Jul 1 at 16:30 This is basic web scraping. You need to inspect the source code elements and like @antfuentes87 says , follow the requests. It sounds more like you need to purchase a third party tool to help you. It's also called "scrape" and "scraping" – dbmitch Jul 1 at 16:44 ...

copy single row from multiple worksheets into new worksheet

Image
copy single row from multiple worksheets into new worksheet I'm not a developer, but was recently hired for a newly created position, meaning I'm trying to create reports and things from scratch that have never been done before. The IT department doesn't have time to teach me and so I'm trying to learn VBA and Access and other advanced data analysis tools, but I don't understand how to write code to the extent I need it yet. I used several things from these forums, but I've been lucky enough to mostly copy and paste to get what I need. I copied this from this forum (second answer): copy the same row from multiple sheets into one sheet in excel This is the code I copied: Sub copyrow() Dim Nrow As Long, Nsheet As Long Dim i As Long Nrow = 7 Nsheet = 6 For i = 1 To Nsheet - 1 Sheets(i).Cells(Nrow, 1).EntireRow.Copy Sheets(Nsheet).Cells(i, 1) Next i End Sub I tested it and it worked, but I didn't realize that Nsheet meant it would go to the 6th sheet and rep...