excel

Excel VBA script - stealing focus

一世执手 提交于 2021-01-29 21:35:55
问题 I'm working on a script that pings computers from a list periodically and returns information. My problem is, whenever the the script is running, it steals focus from other excel windows. For example if if I'm typing in another workbook when the scrip runs, it jumps (to the cell that was last selected) and continues writing in the cell. Here is the script: Sub autoping_cb() Dim c As Range Dim thePing As Variant Dim TryCount As Integer Dim TryAgainCount As Integer Dim TryNextRun As Boolean

AttributeError: 'collections.OrderedDict' object has no attribute 'iloc'

一笑奈何 提交于 2021-01-29 21:30:55
问题 import pandas as pd file = 'D:/myproject/chatbot_database.xlsx' xl = pd.read_excel(file) print(xl) #this prints fine print(xl.iloc[0, 1]) #this throws an error The error message is: AttributeError: 'collections.OrderedDict' object has no attribute 'iloc' I have tried searching through stackoverflow and googled this for 2 days but i just don't seem to be able to get an answer so i am posting this question. So the main issue is that this code works on my computer but it does not work on my

Error with copy paste due to merged column cells

二次信任 提交于 2021-01-29 21:00:23
问题 I want to copy paste values from 4 columns in one worksheet into 4 columns of another worksheet depending on whether the values in a single column are null or not. Following is my code: Private Sub CommandButton1_Click() Dim lastrow As Long, erow As Long lastrow = Worksheets("jun").Cells(Rows.Count, 1).End(xlUp).Row erow = 20 For i = 8 To lastrow If Worksheets("jun").Cells(i, 16).Value <> "" Then Worksheets("jun").Cells(i, 16).Copy Worksheets("jun").Paste Destination:=Worksheets("test").Cells

Specify Printer when Printing Files

烂漫一生 提交于 2021-01-29 20:52:39
问题 I have a macro that prints all files within a specific folder but each time it opens a file it asks which printer to print from. I want to enter the printer name or IP instead of asking the user or using the default printer. Sub PrintDespatches() Dim wb As Workbook, ws As Worksheet Dim FileName As String, path As String Set wb = ActiveWorkbook Set ws = ActiveSheet path = "Z:\Customer Operations\2021\Despatches\*.csv" FileName = Dir(path, vbNormal) Do Until FileName = "" Application

MSXML2.XMLHTTP fails to send request cookie header

风流意气都作罢 提交于 2021-01-29 20:47:27
问题 I'm trying to create some automated web searches in this website using Excel VBA but in order to use it, you need to agree with it's terms and conditions. The website then stores your agreement in a cookie "agree=True". But, while using MSXML2.XMLHTTP , I'm not able to set the cookie request header using setRequestHeader , so it redirects me to the usage agree page on every request. I know there's a bug using MSXML2 as stated here, but I don't see how I can use the workaround provided in the

Excel: Returning characters to the left and right of the last (or second to last) occurrence?

纵饮孤独 提交于 2021-01-29 20:44:04
问题 I have a string like this: 100 Stupid Street ; Government Tower 7; Chicago Palm, MA 92111 I want to return all the characters to the left of the last semicolon. To the left of the last semicolon would be: 100 Stupid Street ; Government Tower 7 That was step 1. I would also like to extract characters from this string: Chicago Palm, MA 92111 I want to return all the characters to the right and left of the second to last space. So, To the right of the second to last space would be: MA 92111 To

ILOG CPLEX / OPL dynamic Excel sheet referencing

半腔热情 提交于 2021-01-29 20:39:12
问题 I'm trying to dynamically reference Excel sheets or tables within the .dat for a Mixed Integer Problem in Vehicle Routing that I'm trying to solve in CPLEX (OPL). The setup is a: .mod = model, .dat = data and a MS Excel spreadsheet I have a 2 dimensional array with customer demand data = Excel range (for coding convenience I did not format the excel data as a table yet) The decision variable in .mod looks like this: dvar boolean x[vertices][vertices][scenarios] in .dat: vertices from

Openpyxl - Transfer range of rows from a worksheet to another

此生再无相见时 提交于 2021-01-29 20:27:29
问题 I want to take a certain part of data from a sheet and copy it to another sheet. So far, I have a dictionary with key as start row and value as end row. Using this, I would like to do the following: -Get the first range from sheet0 and append it to sheet1 -Get the second range from sheet0 and append it to sheet2 -Get the third range from sheet0 and append it to sheet3 I tried the following: #First range starts at 1 and ends at 34, second range from 34-52 and third from 52-75 myDict = {1: 34,

Apache POI throwing OOM error when trying to password protect modest sized XLSX workbooks (~=80MB)

蹲街弑〆低调 提交于 2021-01-29 20:12:45
问题 using java 8 and apache POI and POI-OOXML 3.14 Here's my method: private static void encryptXlsx(String inputPath, String outputPath, String password) throws IOException, InvalidFormatException, GeneralSecurityException { //create a new workbook Workbook wb = WorkbookFactory.create(new File(inputPath)); //Add password protection and encrypt the file POIFSFileSystem fs = new POIFSFileSystem(); EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile); Encryptor enc = info.getEncryptor();

Online search bar values after export from excel not clicking automatically tag identify wrong

空扰寡人 提交于 2021-01-29 20:01:01
问题 I am exporting values from two cells online on a webpage which is running correctly. However, I have to manually press enter as Click is not automatically working in ElementbyId tag selection ("locationSearchTextBox"). After wards, I manually press enter and inspect element to import the elevation result back to excel. I need help in automating these final two steps. I am new in learning about tag classes, id name etc. Probably might be choosing wrong due to ignorance. Help is appreciated.