excel-vba

How to pass multiple values to stored procedure parameter that running from VBA?

跟風遠走 提交于 2020-01-06 14:11:04
问题 I got situation. I have created VBA that calls SP with 2 parameters. How Can I pass 2 values to each parameter? below code as ex, passing single value to each parameter: cmd.Parameters.Append cmd.CreateParameter("@Class", adVarChar, adParamInput, 40) cmd.Parameters("@Class").Value = "H" cmd.Parameters.Append cmd.CreateParameter("@Color", adVarChar, adParamInput, 40) cmd.Parameters("@Color").Value = "Black" Now I want to pass "M","Yellow" also. How can I achieve this? Do I need to do any

Add 3 rows to existing vba code

∥☆過路亽.° 提交于 2020-01-06 13:58:53
问题 Below is vba code that I am using now. Edit details at the bottom. Sub AddBlankRows() ' Dim iRow As Integer Range("a1").Select ' iRow = 1 ' Do ' If Cells(iRow + 1, 1) <> Cells(iRow, 1) Then Cells(iRow + 1, 1).EntireRow.Insert shift:=xlDown iRow = iRow + 2 Else iRow = iRow + 1 End If ' Loop While Not Cells(iRow, 2).Text = "" ' End Sub The above vba code I found (googling) in one of Stackoverflows questions that someone has asked, and it worked for my purpose. However I cannot locate it to give

Add 3 rows to existing vba code

限于喜欢 提交于 2020-01-06 13:58:09
问题 Below is vba code that I am using now. Edit details at the bottom. Sub AddBlankRows() ' Dim iRow As Integer Range("a1").Select ' iRow = 1 ' Do ' If Cells(iRow + 1, 1) <> Cells(iRow, 1) Then Cells(iRow + 1, 1).EntireRow.Insert shift:=xlDown iRow = iRow + 2 Else iRow = iRow + 1 End If ' Loop While Not Cells(iRow, 2).Text = "" ' End Sub The above vba code I found (googling) in one of Stackoverflows questions that someone has asked, and it worked for my purpose. However I cannot locate it to give

How to copy then paste formulas from one workbook to another with VBA

倖福魔咒の 提交于 2020-01-06 13:53:34
问题 I have an existing VBA code that copies an Excel worksheet from my source workbook ( Sourcewb ) into a new destination workbook ( Destwb ) but pastes values only. I need a specific range ( D31:E38 ) in the Destwb to include the formulas from the source workbook. I found this code: Range("A1:I1105").Copy Sheets("Sheet2").Range("B2") On this site (another question) that seems related but don't know how to modify it to work in my application. I have added a comment line " 'Insert total formulas

Triple Quotes when saving an excel file as csv VBA

霸气de小男生 提交于 2020-01-06 12:43:30
问题 I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World" but I'm getting """Hello World""" when I open the CSV file. the CSV is comma delimited edit: if I save it without the quotes, its save like Hello world Do While xExcelFile <> "" newFileName = Replace(xExcelFile, " ", "_") '***************************************************** For Each c In Range("A1").CurrentRegion If Not IsNumeric(c.Value) Then c.Value = Chr(34) & c.Value & Chr(34) End

Selecting entire column after searching for header name

独自空忆成欢 提交于 2020-01-06 12:43:17
问题 Trying to teach myself VBA and am very new to this. Stackoverflow has been an awesome resource so far so I figured I'd ask it here. What I want it to do is find the cell named "Reference," then copy the column below it. For some reason I can't find this anywhere online and figured I'd bite the bullet and submit a question. Thanks. 回答1: It depends on what you mean by "cell named". If the cell is in fact named "Reference" (i.e. if you have renamed the range of cell A1 to Reference , you can

Triple Quotes when saving an excel file as csv VBA

别等时光非礼了梦想. 提交于 2020-01-06 12:43:09
问题 I'm getting triple quotes on each cell when saving an excel file as CSV, it needs to be like "Hello World" but I'm getting """Hello World""" when I open the CSV file. the CSV is comma delimited edit: if I save it without the quotes, its save like Hello world Do While xExcelFile <> "" newFileName = Replace(xExcelFile, " ", "_") '***************************************************** For Each c In Range("A1").CurrentRegion If Not IsNumeric(c.Value) Then c.Value = Chr(34) & c.Value & Chr(34) End

MS Excel macro deleting duplicate rows and sum their values

為{幸葍}努か 提交于 2020-01-06 12:38:13
问题 I'm very briefly familiar with vba and I cannot work out how to amend the following script to make it do what I expect. Basically I have 5 column excel. Column A are the values I would like to sum, providing that B and C and D and E are unique as a row. I found the following script, which does nearly what I need: Option Explicit Sub RedoDataset() Dim LastCol As Long Dim LastRowData As Long Dim LastRow As Long Dim Ctr As Long Dim CompanyArr Dim RowFoundArr Dim SumArr Dim Rng As Range Dim

VBA Intermittent ByRef Error - Format function

為{幸葍}努か 提交于 2020-01-06 12:16:24
问题 I'm newer to VBA than VB. I've had circumstances while using ADO.NET where the project gets corrupted and you, for lack of a better word, break your project. This procedure is from a larger project that pulls together automated reports for call center agent performance and specifically will find the last seven days results then delete any other values within that range to be calculated by another sheet in the workbook. Backstory: I've used this procedure for about three weeks with no issue.

VBA Intermittent ByRef Error - Format function

我的未来我决定 提交于 2020-01-06 12:15:53
问题 I'm newer to VBA than VB. I've had circumstances while using ADO.NET where the project gets corrupted and you, for lack of a better word, break your project. This procedure is from a larger project that pulls together automated reports for call center agent performance and specifically will find the last seven days results then delete any other values within that range to be calculated by another sheet in the workbook. Backstory: I've used this procedure for about three weeks with no issue.