excel

Reordering Multiple Columns in Excel VBA

落爺英雄遲暮 提交于 2021-02-07 17:26:57
问题 Is there a way to create a 'permutation' macro where you input a set of columns (A....Z) and it gives a chosen alternate ordering (e.g. (B,A,E,D,C,...,Z))? I imagine this is something that has been done before but it is surprisingly hard to find any precedent. Initially I was thinking of copying / pasting using Range().Copy / .Paste in a tedious way or similarly with Columns , that is: Columns("C:C").Insert Shift:=xlToRight Columns("D:D").Cut Columns("A:A").Insert Shift:=xlToRight Columns("G

Add checkboxes to UserForm based on cell value

送分小仙女□ 提交于 2021-02-07 17:24:17
问题 I'm very new to VBA, just 3 days... but i found it very useful and easy to use, but now i'm facing a problem. I need to make a UserForm with different Checkboxes, but i need them to be added automatically based on the information used in one of the columns of a Sheet. I believe i can use the For .. Each .. Next but i really don't know how to fill the Checkboxes. This is the only solution that i have right now, but i can't make differents Checkboxes, only one. For Each rCell In Range("B1:B" &

ProgrammingError: can't adapt type 'set'

旧巷老猫 提交于 2021-02-07 14:53:21
问题 I am importing Excel data into postgreSQL using Python and running into an Programming Error. I did research the issue and found out it has something to do with postgreSQL. Can someone please provide assistance. import psycopg2 import xlrd book = xlrd.open_workbook("T:\data.xlsx") sheet = book.sheet_by_name("HCSData") database = psycopg2.connect (database = "", user="") cursor = database.cursor() delete = """Drop table if exists "Python".hcsdata""" print (delete) mydata = cursor.execute

Set Excel Range Formatting With Array

六月ゝ 毕业季﹏ 提交于 2021-02-07 14:52:17
问题 I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... 回答1: @ExcelHero has pointed out to me how to get this done, so here's how. If your range is horizontal, then just feed it an array built of Format strings: [a1:c1].NumberFormat = Array("hh:mm", "General", "$#,##0.00") If your range

Copy first row in excel workbook to a new excel workbook

青春壹個敷衍的年華 提交于 2021-02-07 14:52:14
问题 How do I get the first row in an excel workbook & save it to a new excel workbook using .net c#? I dont know the amount of columns so need to get entire row. This what I have but the new workbook is blank (no row copied) Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(file); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRangeHeader = xlWorksheet.get_Range("A1", "A1").EntireRow; Excel.Workbook xlWorkbookNew = xlApp.Workbooks.Add(); Excel._Worksheet xlWorksheetNew =

Set Excel Range Formatting With Array

半腔热情 提交于 2021-02-07 14:52:12
问题 I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... 回答1: @ExcelHero has pointed out to me how to get this done, so here's how. If your range is horizontal, then just feed it an array built of Format strings: [a1:c1].NumberFormat = Array("hh:mm", "General", "$#,##0.00") If your range

Set Excel Range Formatting With Array

﹥>﹥吖頭↗ 提交于 2021-02-07 14:50:37
问题 I have, in the past, used a variant array to populate a range of multiple Excel cells. I'm wondering, is there a way to do the same thing with cell formatting? I'd rather not go cell by cell, and it'd be nice to minimize the number of calls to get an Excel range... 回答1: @ExcelHero has pointed out to me how to get this done, so here's how. If your range is horizontal, then just feed it an array built of Format strings: [a1:c1].NumberFormat = Array("hh:mm", "General", "$#,##0.00") If your range

Copy first row in excel workbook to a new excel workbook

£可爱£侵袭症+ 提交于 2021-02-07 14:50:30
问题 How do I get the first row in an excel workbook & save it to a new excel workbook using .net c#? I dont know the amount of columns so need to get entire row. This what I have but the new workbook is blank (no row copied) Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(file); Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Excel.Range xlRangeHeader = xlWorksheet.get_Range("A1", "A1").EntireRow; Excel.Workbook xlWorkbookNew = xlApp.Workbooks.Add(); Excel._Worksheet xlWorksheetNew =

ProgrammingError: can't adapt type 'set'

≡放荡痞女 提交于 2021-02-07 14:50:29
问题 I am importing Excel data into postgreSQL using Python and running into an Programming Error. I did research the issue and found out it has something to do with postgreSQL. Can someone please provide assistance. import psycopg2 import xlrd book = xlrd.open_workbook("T:\data.xlsx") sheet = book.sheet_by_name("HCSData") database = psycopg2.connect (database = "", user="") cursor = database.cursor() delete = """Drop table if exists "Python".hcsdata""" print (delete) mydata = cursor.execute

Excel VBA: how to add data validation list which contain comma included value without using reference of Range

我的未来我决定 提交于 2021-02-07 14:16:49
问题 I need to add a data validation list to Cell whose few values contains comma. I have the same problem like this Data Validation to Include Comma Character But I can't reference a range, because I am creating a new workbook and feed its cell with the data validation list. So reference is not working for me and since some values contain comma so I can't set the Range into String and use that after Formula1 .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ xlBetween, Formula1