excel

Importing Excel into DataGridView

怎甘沉沦 提交于 2021-01-28 23:56:05
问题 I'm making a program where two databases are merged together.... I can import an excel spreadsheet into a DataGridView with this code: string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""; DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb"); DbDataAdapter adapter = factory.CreateDataAdapter(); DbCommand selectCommand = factory.CreateCommand(); selectCommand.CommandText = "SELECT *

VBA (Microsoft Excel) replace Array with String

夙愿已清 提交于 2021-01-28 23:07:06
问题 I know this is completely wrong, but at the moment, I really don't know how to do it. In Microsoft Excel, I want to replace all the values on the "OldValues" string, by a fixed string "NewValue". How is that possible? LBound and Ubound are wrong to be used, right? Sub Replace() Dim sht As Worksheet Dim OldValues As Variant Dim NewValue As String Dim x As Long OldValue = Array("old1","old2","old3") NewValue = "allnew!" For x = LBound(OldValue) To UBound(NewValue) For Each sht In ActiveWorkbook

Append to Excel from Access using VBA

限于喜欢 提交于 2021-01-28 23:05:11
问题 With this particular problem I can’t get the code to append the exported data from Access to Excel. I have created an simple Access database with some data shown on a form. After that it is possible to export the shown record to Excel using the code. So far so good. But when I export the next record it overwrites the previous exported data on row one in Excel. I want the code to append to the next row and so on. I have found some topics on how to append with “ActiveCell.Value” and “ActiveCell

VBA (Microsoft Excel) replace Array with String

非 Y 不嫁゛ 提交于 2021-01-28 22:56:50
问题 I know this is completely wrong, but at the moment, I really don't know how to do it. In Microsoft Excel, I want to replace all the values on the "OldValues" string, by a fixed string "NewValue". How is that possible? LBound and Ubound are wrong to be used, right? Sub Replace() Dim sht As Worksheet Dim OldValues As Variant Dim NewValue As String Dim x As Long OldValue = Array("old1","old2","old3") NewValue = "allnew!" For x = LBound(OldValue) To UBound(NewValue) For Each sht In ActiveWorkbook

Append to Excel from Access using VBA

时间秒杀一切 提交于 2021-01-28 22:46:25
问题 With this particular problem I can’t get the code to append the exported data from Access to Excel. I have created an simple Access database with some data shown on a form. After that it is possible to export the shown record to Excel using the code. So far so good. But when I export the next record it overwrites the previous exported data on row one in Excel. I want the code to append to the next row and so on. I have found some topics on how to append with “ActiveCell.Value” and “ActiveCell

write list of dataframes to multiple excel files

筅森魡賤 提交于 2021-01-28 22:13:11
问题 I have a list of dataframes. Conveniently named: list.df and the objects, which are dataframes, are just this: list.df[[1]] list.df[[2]] list.df[[3]] I am trying to use lapply to write each of the list.df objects to a seperate excel sheet. I can't use the xlsx library because my workplace disables everything Java... so I've been trying write_xlsx. I've tried the following: lapply(names(list.df), function (x) write_xlsx(list.df[[x]], file=paste(x, "xlsx", sep="."))) But nothing happens. Any

Edit Form Control Label Caption on VBA

匆匆过客 提交于 2021-01-28 22:00:42
问题 Trying to edit the text of a form control label named lblsearchreminder and make sure that the font is Arial and size 20. I am pulling the edited text from an ActiveX textbox1 and trying to make that the caption of the label. If anyone has any insight I would greatly appreciate it. Sub btnAltCustomSearch_Click() Dim strTextBox As String If Worksheets("User Interface").OLEObjects("TextBox1").Object.Value = "" Then ErrorX.Show Else strTextBox = Worksheets("User Interface").OLEObjects("TextBox1"

Search for text, copy offset rows

强颜欢笑 提交于 2021-01-28 20:48:03
问题 I wrote a macro to read a .csv file. It places the data in Sheet2. I need to copy a block of data that begins in the row that follows the text string "BP Error". The data that precedes this string can vary in length, but the block of data I'm interested in is of a fixed size. I'd like to copy this block of data into Sheet1. I tried doing a sub-routine that would search for "BP Error" but I kept getting stuck trying to do Offset copying. I need the next 18 rows of data following that string of

Wanted: DXL code to export OLE object to Excel and specify “Placement” parameter

倾然丶 夕夏残阳落幕 提交于 2021-01-28 20:44:51
问题 I have working DXL code to export a DOORS module to Excel, including sizing pictures and placing them over the desired cell. (Slightly modified version of GalacticSolutions script ). The default export so far as I can tell applies the parameter "Move but do not size with cell." I'd like to specify "Move and size with cell." This is easy enough to do with an Excel VB macro after the export, but I'd like to avoid that step. I'm hoping there's some Oleput() string that will do this, but can't

Save a file with a name that corresponds to a cell value

时光总嘲笑我的痴心妄想 提交于 2021-01-28 19:49:59
问题 Background: I'm working with a macro that transfers data between different workbooks. One of the workbooks is a conduit for data and doesn't change. The other workbook is a blank form that is populated, saved as a specific name and then reused. Problem: The workbook being saved needs to use the contents of a cell in the conduit workbook for it's name. I found a similar post here. The answer gives me a syntax error. Sub TestTestTestTest() ' ' TestTestTestTest Macro ' ' Dim name As String name