vba

Number of rows based on the cell value (loop with copy)

戏子无情 提交于 2021-02-08 04:49:20
问题 I would like to sync my address list with the number shown in the cell at the front sheet. The situation looks as follows: In the cell D41 I have the number of flats. Now, when I open the "Address list" sheet I want to have the first row instantly copied 40 times down (marked with red). I know, that it can be described as a loop, this is why I tried this code: Original source here: Relocation of multiple images with ID changing Private Sub AddressList() Dim i As Long Dim rg As Range, rg2 As

accessing individual array elements in VBA function

前提是你 提交于 2021-02-08 04:49:18
问题 VBA newbie here. I am trying to pass an array ( it is static, but please answer for dynamic range as well ) to a function. Then assign individual array elements to unique variables and use these variables in a custom formula. I just browsed around and wrote the code but keep getting #VALUE! error. The gist of the code is below: Public Function mytest(ByRef arr1 As Range) Dim A As Double Dim B As Double A = arr1(0) B = arr1(1) mytest = A + B 'The actual formula is a bit more complicated than

Sorting a vector in Excel VBA

回眸只為那壹抹淺笑 提交于 2021-02-08 04:29:15
问题 I'm VERY new to Excel VBA. I want to write a function that offsets the cells in the current vector (the range selected by the user) by an amount also specified by the user. The cells must be moved up out of the array by "n", and must then be displayed at the bottom of the same array after the remaining cells have moved up to take the place of the cells shifted up and out of the array. Any advice will be greatly appreciated, the current code I wrote is not working and I know too little to help

VLOOKUP() Alternative using Arrays

Deadly 提交于 2021-02-08 03:48:52
问题 I’ve been experimenting with arrays in an effort to find a faster alternative to VLOOKUP(), which can take a long time to execute with very large data sets. Arrays are not my forte, and I’m stuck on the code below. I have searched SO and many other sites, grabbing snippets of code here and there, but I’ve hit a brick wall when it comes to putting it all together. The data is simply: A1:A5 the list of values to lookup (1,2,3,4,5) C1:C5 the range to ‘find’ the values (2,4,6,8,10) D1:D5 the

Optimize performance of Removing Hidden Rows in VBA

99封情书 提交于 2021-02-08 03:42:25
问题 I am using the following code to remove hidden/filtered lines after applying autofilters to a big sheet in VBA (big means roughly 30,000 rows): Sub RemoveHiddenRows() Dim oRow As Range, rng As Range Dim myRows As Range With Sheets("Sheet3") Set myRows = Intersect(.Range("A:A").EntireRow, .UsedRange) If myRows Is Nothing Then Exit Sub End With For Each oRow In myRows.Columns(1).Cells If oRow.EntireRow.Hidden Then If rng Is Nothing Then Set rng = oRow Else Set rng = Union(rng, oRow) End If End

Sending JSON POST request in VBA

时光怂恿深爱的人放手 提交于 2021-02-08 03:40:41
问题 I have the following JSON POST sample code which I am trying to convert to VBA for Excel: POST /services/shipper/orders HTTP/1.1 Content-Type: application/json User-Agent: Mozilla 5.0 Host: qa.etowertech.com X-WallTech-Date: Tue, 06 Jan 2018 21:20:27 GMT Authorization: WallTech test5AdbzO5OEeOpvgAVXUFE0A:79db9e5OEeOpvgAVXUFWSD Here is the code I came up with: With JsonHTTP .Open "POST", "http://qa.towertech.com/services/shipper/orders", False .setRequestHeader "RequestName", "application/json

Sending JSON POST request in VBA

こ雲淡風輕ζ 提交于 2021-02-08 03:40:34
问题 I have the following JSON POST sample code which I am trying to convert to VBA for Excel: POST /services/shipper/orders HTTP/1.1 Content-Type: application/json User-Agent: Mozilla 5.0 Host: qa.etowertech.com X-WallTech-Date: Tue, 06 Jan 2018 21:20:27 GMT Authorization: WallTech test5AdbzO5OEeOpvgAVXUFE0A:79db9e5OEeOpvgAVXUFWSD Here is the code I came up with: With JsonHTTP .Open "POST", "http://qa.towertech.com/services/shipper/orders", False .setRequestHeader "RequestName", "application/json

Spacebar not working at end of the line in Excel VBA Editor

百般思念 提交于 2021-02-08 03:35:45
问题 I moved my personal.xlsb to my new laptop and I am having a strange issue. The spacebar is not working at the end of the line except it's a totally empty line. Example 1 : Not working example | Not working Example 2 : Working example | Would work When I was pressing the spacebar, the text select pointer didn't move, but the position indicator is blinking between the original position and (col+1). Pointer position indicator image 回答1: I had the same issue. I found if I turned off AutoSave, it

Updating an .xml document according to a .csv file

独自空忆成欢 提交于 2021-02-08 03:25:28
问题 I'm quite of a newbie in VBA, and I'm struggling to find a solution to my problem. Basically, what I need to do is editing some nodes in an .xml file according to the content of a .csv document. In particular, whenever I loop through the XML document (i.e., "C:\Users\xxx\Desktop\ppp.xml") and I stumble upon a particular node (let it be thing ), I need to read the text of that node and look for it in the CSV file (i.e., C:\Users\xxx\Desktop\mycopy.csv"). Then edit the text of a different node

runtime error 462 with internet explorer

↘锁芯ラ 提交于 2021-02-07 22:57:40
问题 I am trying to access a webpage from excel using VBA. I can get internet explorer to launch, and I see the webpage come up, but I get a runtime error 462 when I hit the Do Until internet.ReadyState >= 4 line of code. any ideas? ultimately I want to be able to parse a site and get a list of the links on that site and pick one, and then "click" on that link. suggestions and help would be great. here is the function (that I found on the web) that I am using: Public Sub clicklick() Dim internet