excel

Using “Text to Columns” macro on multiple columns

血红的双手。 提交于 2021-01-29 12:09:09
问题 This image shows the initial state of the columns, in UK format. #value if I try to add 1 to it, False if I run ISNUMBER() on it, and True if I use text to column on entry to swap period & comma. Once in true state, I can use the numbers, but for some this true state isn't reached. Instead, they result in the error handling convert to number diamond that pops up. I used the recorder to record the text to columns procedure on a single column. It produces the following: Range(Range("J2"), Range

Possible for my vba code more compact and simplified

妖精的绣舞 提交于 2021-01-29 12:09:05
问题 My vba code below to check on the userform textbox for any duplicate data on 3 rows. Once duplicate found, it will notified user and select entire row of the duplicate data. Its working and get job done. But, seems like the code quite long and repetitive. Is it possible to simplified and make my code more compact? Im still learning with vba code and dont know much about more advance function to get more compact code. Thank you. Private Sub ISBNTextBox_Exit(ByVal Cancel As MSForms

Running a specific macro on all sheets besides named ones in excel using VBA

谁都会走 提交于 2021-01-29 11:46:26
问题 I have a code which calls other macros to run on specified sheets. Firstly: I was wondering how to tell it to run another macro on all remaining sheets that haven't been previously listed Secondly: I want the above macro to run on the remaining sheets excluding a number of named sheets (e.g. "graphs") Here is my code so far Sub specify_sheets() 'apply appropriate limits to relative sheet Dim sht As Worksheet For Each sht In Worksheets If sht.Name = Worksheets("NB12") Or _ sht.Name =

How to properly save excel file using python?

孤者浪人 提交于 2021-01-29 11:13:53
问题 I have a problem when I'm trying to save and than read excel file in python. So this is my function: import openpyxl import xlrd from xlutils.copy import copy import pandas as pd def write_excel(): wb = openpyxl.load_workbook('8de69ccb60047ce5.xlsx') sheet = wb.active sheet['D18'] = 3 wb.save('8de69ccb60047ce5.xls') df1 = pd.read_excel('8de69ccb60047ce5.xls', sheet_name='Лист1', header=None, skiprows=1, usecols="H,I") print(df1) workbook = xlrd.open_workbook('8de69ccb60047ce5.xls') worksheet

Importing Files csv from Folder into single sheet

别说谁变了你拦得住时间么 提交于 2021-01-29 11:05:56
问题 I was using below code to get the multiple CSV files into single sheet. code is working fine but the issue is that, it should not copy the headers of each file, because each file header is same. Code should copy the first file header not all files. One more thing that i do not want first column to copy all sheets name i have tried to remove that filed but code does not work. Can i get any help. thanks Sub CSV() Dim xSht As Worksheet Dim xWb As Workbook Dim xStrPath As String Dim xFileDialog

Excel VBA: Loop InputBox and add values to cell range

纵饮孤独 提交于 2021-01-29 11:02:19
问题 I have the following code: Private Sub ChangeAccountNames_Click() Dim AccountName As String Dim Rng As Range Dim InputQuestion As String Dim i As Integer Dim s As Worksheet Set s = Sheets("Essential Info") i = Cells(3, 9) Do Set Rng = Sheets("Essential Info").Range("I2:I13") InputQuestion = "Please enter in a bank account name: " & vbNewLine & "Click Close once you are done" AccountName = InputBox(InputQuestion) Rng.Value = AccountName i = i + 1 Loop Until i = 10 End Sub What I need it to do

Sort Data Validation dropdown list within cell

只愿长相守 提交于 2021-01-29 11:01:55
问题 I have implemented a data validation in-cell drop down list that I use to retain multiple values in a column of cells. Currently you can select from the dropdown list in any order and the cell will populate in that order. Is there a way to force the order to stay consistent with the list that is the source for my dropdown? For example: My dropdown list is: Jim Tom Bob Aaron The selections are made in this order: Bob Jim Tom I want the cell to display: Jim, Tom, Bob Below is my current VBA

Filling a cell with a solid color, using OpenXML that preserves otherwise existing sheet format

*爱你&永不变心* 提交于 2021-01-29 11:00:00
问题 The following takes the format of existing sheet sSheet and creates a red font (along with some timestamp content) at A19: using (SpreadsheetDocument document = SpreadsheetDocument.Open(sPath, true)) { IEnumerable<Sheet> sheets = document.WorkbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sSheet); WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheets.FirstOrDefault().Id); Worksheet worksheet = worksheetPart.Worksheet; WorkbookStylesPart styles =

Extract Data from Text File into Excel

£可爱£侵袭症+ 提交于 2021-01-29 10:56:44
问题 I am new to VBA so getting my task done is quite a struggle. Been reading and trying codes from different threads for a few days now to no success. So I am hoping someone could assist me. I have multiple text files that I need to extract data from. But I only need certain data such as DATE-TIME to be placed in the 1st column and CARD NUMBER in the 2nd column. Got codes from this thread >> Extract a single line of data from numerous text files and import into Excel but my output only shows the

Excel throws HRESULT: 0x800A03EC exception when using Range

大兔子大兔子 提交于 2021-01-29 10:55:48
问题 Hello guys! I'm really new to Visual Basic and Excel so i don't know if there's a better way to do what i'm trying to do, but this is not important. I'm trying to set the range for formatting my excel cells with some borders and stuff like that. I don't know how to find the last used cell so i came up with this. range = "A1:AD1" For Each dataRow In dataTable.Rows rowIndex += 1 Next I created the excel sheet from my data table so they have the same columns and rows. My range was calculated