excel-vba

VBA Excel: Paste large array to range

最后都变了- 提交于 2020-01-17 01:22:28
问题 I'm working in VBA for excel. I have an array called "aKey" (1 by 137,000 strings but exact size is subject to change so making code generic is a neccesity). I need to paste aKey to the first column of a a worksheet. So far i have tried Range(.Offset(1,0),.Offset(UBound(aKey)+1,0)).Value = aKey but this seems to only paste 137,000 versions of the first entry of the array. I have also tried Range(.Offset(1,0),.Offset(UBound(aKey)+1,0)).Value = WorksheetFunction.Transpose(aKey) which also didn

Logarithmic averaging preset function in excel - using ranges as input values

ε祈祈猫儿з 提交于 2020-01-16 23:41:13
问题 I need to add my own function for logarithmic averaging to excel but i'm not sure how to have a range of values as an input value or how to make count the number of values in a given range. I have a small amount of experience with programming. The formula i usually use in excel and am looking to implement as a pre-set function is the following: =10*LOG(SUM(10^('range of values'/10)/'number of values in the range')) Can anyone help me out? 回答1: You can try this, you may need to adjust to

Excel screws up my dates when system is set to European date format

纵饮孤独 提交于 2020-01-16 21:58:13
问题 Here's what I'm doing: 1. In Control Panel I set up the system date format as follows: dd/MM/yyyy 2. I create the following simple macro: Sub hello() ActiveSheet.Cells(1, 1) = "10/01/2014" End Sub I run it, and get the following date in the cell (1,1): 01/10/2014 Whenever the date is less then 12 it converts the date to american format (MM/dd/yyyy), and when the date is more than 12 it fails to convert it and writes the date in the cell correctly, but as text. I first discovered this when

Split column text to adjacent columns using Excel VBA

大城市里の小女人 提交于 2020-01-16 19:59:29
问题 I have an Excel sheet with a column containing texts like "Hello there 2005 A" I want to split this text in between two columns, one containing 'Hello there 2005' and the other saying 'A'. I have tried Split function in VBA, but I can't make it loop through the entire column or even come up with a delimeter which will split exactly before the letter 'A'. Results should look something like this: 回答1: try this Option Explicit Sub main() Dim cell As Range Dim strng As Variant Dim rightStrng As

Is there a limitation to the string length with VBA?

不羁岁月 提交于 2020-01-16 19:25:29
问题 I have a large string that comes from an HTML source code (approximately 1,000,000 characters long). I'm using msinet.ocx to view the text from appropriate websites. I've written a small segment of code in order to find a key phrase ("pkid=") that occurs right before a different key phrase ("Component Accessory Matrix"), but it's not working properly. Here's what I have right now: workbench = Cells(columnNumber, 1).Value myURL = "http://beams.us.yazaki.com/Beams/ViewDetails.aspx?topic

Excel VBA - How to clear a dynamic range (from below header, to last row)

亡梦爱人 提交于 2020-01-16 19:24:31
问题 I have a loan amortization schedule that creates the amortization schedule depending on the periods, how can I clear the range, before running the loan amortization again? For example, if I run it for a 10 year period, then run it for a 5 year period, years 6-10 still show up because they haven't been cleared. Here is my code: outRow = 3 With Sheets("Loan") lCol = .Cells(3, .Columns.Count).End(xlToLeft).Column lrow = .Cells(.Rows.Count, lCol).End(xlUp).Row End With Sheets("Loan").Range(Cells

Excel VBA - How to clear a dynamic range (from below header, to last row)

此生再无相见时 提交于 2020-01-16 19:24:11
问题 I have a loan amortization schedule that creates the amortization schedule depending on the periods, how can I clear the range, before running the loan amortization again? For example, if I run it for a 10 year period, then run it for a 5 year period, years 6-10 still show up because they haven't been cleared. Here is my code: outRow = 3 With Sheets("Loan") lCol = .Cells(3, .Columns.Count).End(xlToLeft).Column lrow = .Cells(.Rows.Count, lCol).End(xlUp).Row End With Sheets("Loan").Range(Cells

Excel macro to delete all rows on all worksheets if the value in column AA = 0

こ雲淡風輕ζ 提交于 2020-01-16 19:23:22
问题 I have a workbook containing 197 sheets. I need to delete all rows in each sheet if the value in column AA is zero. Anyone know how to do this? 回答1: If you would like to delete each row if and only if that row's column AA is zero, then the below should work for you. Sub delete0rows() Dim Worksheet As Excel.Worksheet Dim lastRow As Long Dim i As Integer For Each Worksheet In Application.ThisWorkbook.Worksheets lastRow = Worksheet.Cells(Rows.Count, 1).End(xlUp).Row i = 1 Do While i <= lastRow

VBA- Type mismatch error when trying to copy/paste a row from one worksheet to another. Code provided

早过忘川 提交于 2020-01-16 19:20:38
问题 I have been working at this problem for a while now. I have tried several different options, but each one ends up with a different error. As I stated in the title a type mismatch error. The basis for this macro is to move records from a master sheet to other sheets based on criteria from column F. The error occurs in the "Termination" case where it is selecting the cell "B2". Public Sub moveToSheet() Sheets("Master").Select ' Find the last row of data FinalRow = Range("E65000").End(xlUp).Row

Excel, VB - Character Operations & Date Reformating Inside Array

依然范特西╮ 提交于 2020-01-16 19:04:31
问题 ISSUE Large dataset with many improperly or non-uniformly entered dates in a specific field. There are about 19 different ways the dates have been entered in about 60,000 records. Some entries are completely invalid and must be discarded, others must be formatted properly. I am loading the range into an array and then performing the operations. I wrote out the operations as I believe I need, however I need some help in actually getting them working. See code below; error in comments. CURRENT