Posts

Showing posts with the label excel

object variable not set: for loops

object variable not set: for loops I really need quite a bit of help on this so I would really appreciate if you bear with me. I am new to VBA and hence I am facing difficulties running the code. It keeps returning me the error: object variable not set. May I know what is wrong with the code? Thanks in advance for your help! Sub sub_input (dicDat as Dictionary) Dim ws As Worksheet: Set ws =ActiveSheet Dim i As Integer Dim j As Integer Dim vTemp As Variant Range("rInputStart").Parent.Calculate vTemp =Range(Range("rInputStart").Offset(1),_ Range("rInputStart").End(xlDown).Offset(0,2)).value Dim info as string Dim currency As String: currency = vbNullString Dim exchangeRate as String: exchangeRate = vbNullString Dim remark as String: remark = vbNullString For j =1 To 10 info= "info" & CStr(j) info = Range("rInfoManual").value currency= "dl_currency" & CStr(j) exchangeRate = "exchange" ...

office-js customTab & worksheet visibility dose not work in excel 64bit

Image
office-js customTab & worksheet visibility dose not work in excel 64bit Everything is work successfully until I tested my addin in excel 64bit. I have a CustomTab in my manifest.xml , It shows up in the 32bit. But where is nothing in the 64bit. By the way, I had writed GetStarted node in my xml, It dose not work too. CustomTab manifest.xml GetStarted The visibility of worksheet API is not working in 64bit too. https://dev.office.com/reference/add-ins/excel/worksheet . And the Excel.run throw a error Assignment to read-only properties is not allowed in strict mode in sheet.visibility = Excel.SheetVisibility.hidden; Excel.run Assignment to read-only properties is not allowed in strict mode sheet.visibility = Excel.SheetVisibility.hidden; This issue is not suitable for raised here. My Rtd server can not updated cell after gave an initial value like fetching in excel 64bit, But It works well in 32bit. fetching Here is the version of my excel: (16.0.4266.1001)64bit, and test machin...

Need to lock cells (protect from editing) after entering values in google spreadsheet

Need to lock cells (protect from editing) after entering values in google spreadsheet I need to lock the cells on a spreadsheet after entering values (password protect the cells). I am able to write a macro on excel but that goes off when its uploaded to google spreadsheet. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Export to excel using Laravel Excel 3.0

Export to excel using Laravel Excel 3.0 How to export to excel with Maatwebsite/Laravel-Excel version 3.0 within the image? Maatwebsite/Laravel-Excel I do the export with Exports Class, I need to export with the image, this is the code all I got. https://paste.laravel.io/34e11e43-73c4-42c6-adcc-0206946a8fc8 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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...

Copying to a specific sheet: openpyxl - destination sheet ignored when using copy_worksheet

Copying to a specific sheet: openpyxl - destination sheet ignored when using copy_worksheet Per this answer and these documents I tried to specify a source and target sheet to write to, but when I do, the results are the same as if I hadn't specified a target: source target from openpyxl import load_workbook wb = load_workbook('MyFile.xlsx') ws = 'Sheet1' idx = book.index(ws) new_ws = 'Test' book.create_sheet(new_ws, idx+1) source = book[ws] target = book[new_ws] target = book.copy_worksheet(source) wb.save('Output.xlsx') vs source = book[ws] book.copy_worksheet(source) wb.save('Output.xlsx') Both result in a new worksheet called Sheet1 Copy added to the end of the workbook. How to a copy a sheet into another empty sheet, or specific location within the workbook? Sheet1 Copy 1 Answer 1 I'm still not sure if there's a bug in the ability for copy_...

how to conditionally hide a row in excel if condition is not met

how to conditionally hide a row in excel if condition is not met I am using BI Publisher add-in in excel , and I want to hide a row of <?net_salary?> if the value equal 0 my code : <?net_salary?> <xsl:choose> <xsl:when test="number(.//NET_SALARY) != 0"><xsl:value-of select="(.//NET_SALARY)"/></xsl:when> <xsl:otherwise> ** hide row ** </xsl:otherwise> </xsl:choose> 1 Answer 1 If you put an IF statement at the beginning of the row before anything else, and then end if at the end of the row after everything else, it will not render the row if the condition is not met. For more information, there's details in the BI Publisher Report Designer guide on IF statements. IF end if Example: <?if:net_salary<>'0'?> Table cells and data elements <?end if?> <?if:net_salary<...

Connecting Interactive Broker's API via Excel

Connecting Interactive Broker's API via Excel I am interested in doing algorithmic trading and have started a project for work. I have downloaded the IB Software and corresponding API. I have selected port "7496" and have enabled "activeX and socket clients" and "DDE Clients". I have also allowed Macros on my computer. After I presume I've set it up, I attempt to pull market data and I get an error. It attempts to call an executable using my garbage username "david123r" but modifies it slightly as illustrated in picture. It's possible it's because I don't have the TWS API add-in for Excel but I am unsure whether this was only necessary for previous versions. Any feedback would be greatly appreciated as I am dead in the water. I apologize if my post isn't formatted correctly as I am new and will make changes if deemed necessary. Thanks in advance! IB's TWS Latest version for 32-bit (an excel requirement) IB's API TW...

Excel using a string as a cell reference

Excel using a string as a cell reference I am trying to create a dynamic graph that checks which financial year it is and then only graph the data for that range of months. I have a 'SUMMARY DATA' sheet that has rows with the date range 1/7/18 || 31/7/18 and so on for every month. I am trying to create a dynamic range that takes these values and then have the graph use those cell references. Currently I am using a fancy concatenate function that gives me 'SUMMARY DATA'!$H$25:$H$36 (In cell DASHBOARD!$AJ$24 ) which is the range that I want to reference. I can't seem to get this working with a graph though. If I place =DASHBOARD!$AJ$24 as the series values, the graph doesn't update with the correct values (just 0 for every column). If I try using =INDIRECT(DASHBOARD!$AJ$24) , it gives me a "That function isn't valid" error. 'SUMMARY DATA'!$H$25:$H$36 DASHBOARD!$AJ$24 =DASHBOARD!$AJ$24 =INDIRECT(DASHBOARD!$AJ$24) Not sure how to progress ...

writer. save doenst update excel sheet in loop

writer. save doenst update excel sheet in loop I'm trying to append the rows of excel sheet using pandas in python. The problem is the code runs and at the end i only see 1 row added in sheet not all the numbers of rows to which the loop is called to insert the data. Following is the code of Init where i Read the data frames def __init__(self,readLink): self.fileName = 'data.xlsx' if readLink==0: self.linksToRead = 10000 else: self.linksToRead = readLink self.linkCount = 0 self.wordsList = self.df = pd.read_excel(self.fileName, sheetname='Sheet1') if len(self.df) > 0: self.parsedLinks = self.df['link'].tolist() else: self.parsedLinks= self.urlList = self.writer = pd.ExcelWriter(self.fileName) self.Start('https://www.bbc.com/urdu/pakistan-44652896') Following the the code that runs inside the loop and intend to append the excel rows in sheet using dataframes. df2 = pd.DataF...

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...

EXCEL VBA: getting the integer value of mm in today's date

EXCEL VBA: getting the integer value of mm in today's date novice programmer here and it's my first question here. I'm interested in doing some invoicing using excel, and a part of that is generating invoice numbers, e.g. 1870001-1879999, referring to the year 2018, the month of July, and the 1st to 9999th invoice of this month. To do this, I've written a bit of code: Private Sub Workbook_Open() Dim MValue As String Dim XValue As Integer MValue = Format(Date, "mm/dd/yy") LValue = Left(MValue, 2) XValue = CInt(LValue) Range("K1").Value = XValue End Sub This would give me "7" as an integer in the cell K1, which I can then multiply by 10000 and add to 1800000 to give the baseline value of 1870000. I have two questions: 1) what's a better way to do this problem? My method seems incredibly long. (dates are stored awkwardly in excel) 2) why is it that: Range("K1").Value = XValue * 10000 causes an error? Thanks. ...