excel-vba

Counting coloured cells doesn't work with conditional formatting in Excel

让人想犯罪 __ 提交于 2020-01-06 07:44:08
问题 Trying to count the number of certain coloured cells on my worksheet using this peice of VBA code : Function CountRed(MyRange) CountRed = 0 For Each Cell In MyRange If Cell.Interior.Color = RGB(255, 0, 0) Then CountRed = CountRed + 1 End If Next Cell End Function Basically, counts the number of red cells. Now this works fine if I colour them myself but if i put conditional formatting in my worksheet to colour these cells it doesnt work. Here is my condition : =AND(NOT(ISBLANK(A3)),ISBLANK(D3)

Subscript out of range error - VBA error

社会主义新天地 提交于 2020-01-06 07:22:10
问题 I keep getting subscript out of range for the following code, I'm new to VBA so would greatly appreciate your help. I'm trying to reference a table that contains various source workbooks and copy the data from here to "target" workbooks also contained in the sTable range. Thanks, Ronan Sub Import() Dim sTable As String ' Source table Dim sTarget As String ' Target range for output Dim sHeader As String ' Header row from the input data Dim sFileName As String ' File name to read from Dim

Trouble with vba error 91 when using With, Range and .Find

这一生的挚爱 提交于 2020-01-06 07:14:34
问题 i would like to find the address of the cell containing the value "USD" in below mentioned code. though, the system throws me an error 91 saying that an object variable has not been set. i found some info online on error 91 but i still don't get where and how to set the right object. help is appreciated. thanks Sub searchAdress() Dim searchAdress As Range With Workbooks("Umrechnungskurse1.xlsm").Sheets("Tabelle1").Range("A2:S2") searchAdress = .Find("USD", LookIn:=xlValues) End With MsgBox

Excel macro to create line chart excluding columns in between

混江龙づ霸主 提交于 2020-01-06 07:00:46
问题 I want to create line chart in excel macro. I have below table in excel. First Line Chart contains range of values from Cell A and B. Second Line Chart contains range of values from Cell A and C. Third Line Chart contains range of values from Cell A and D. ActiveSheet.Shapes.AddChart.Select ActiveChart.SetSourceData Source:=Range("A1:D3") ActiveChart.ApplyDataLabels ActiveChart.ChartType = xlLine Above code produces only one Line Chart for range A1 to D4. 回答1: This is a good question that the

VBA code to overwrite cells through moving /shifting up a range of cells

纵然是瞬间 提交于 2020-01-06 06:53:26
问题 Hi there i have a data table, as seen from the picture, which changes from time to time. For example if there new data coming up for March'15 i would have to copy and overlap cells from April'14 onwards to March'14. Thereafter i would fill in the information for march'15 on the blank cell that was previously filled with feb'15 information. I was wondering if there is any vba code to help move or shift the range to the preferred row of cells that already has existing data ( more of a code to

Opening a workbook with VBA/macro is making it read only?

爱⌒轻易说出口 提交于 2020-01-06 06:45:08
问题 I would like my code to open a workbook (always the same one), detect the first free row, write to just two cells in that row, and then save/close the workbook. This seems like a simple problem, but the macro seems to be opening a copy of the file, and then locking it for editing. Can you see any errors in my open code? I know that the file opens and that the row search works, but then it 1. never writes to the cells, and 2. locks the file. Function WriteToMaster(Num, Path) As Boolean

Inaccurate output of Dynamic Named Range

早过忘川 提交于 2020-01-06 06:41:35
问题 I am using the exact same code to name a dynamic range in two workbooks. I use Workbook TestBook1 for testing the code before implementing it to the body of the general code in Workbook 111. The code is: Dim HDaER As Worksheet Dim HDaERReturnLR As Long Dim HDaERReturnLC As Long Dim HDaERReturnsDNR As Range Dim HDaERReturns As String Set HDaER = Sheets("HistoricalDataandExcessReturns") With HDaER.Cells(108, 2).CurrentRegion HDaERReturnLR = .Find(What:="*", After:=HDaER.Cells(107, 1), _ LookIn:

Filter Only matching results in ListBox Excel from TextBox text

微笑、不失礼 提交于 2020-01-06 06:29:40
问题 I have a user form with a textbox and a listbox. I would like a user to be able to enter text into the textbox, and have the listbox filter results based on their typing. So far, I have managed to get the ListBox to highlight matching results in the list, but not filter out results that dont match. I have also run into the issue of my code not identifying multiple matching records, not sure what I need to add to get this to happen. Private Sub TextBox3_Change() 'searches ListBox3 for match

How can I parse the array objects inside this JSON list in VBA?

烈酒焚心 提交于 2020-01-06 06:25:50
问题 My JSON is: {"totalCount":431,"messages":[],"results":[{"aliasList":["User Id","Name","last name"],"results":[[71512,"joe","adams"],[23445,"jack","wilson"],[34566,jill,goodman]],"executionDate":151134568428}],"Class":"com.zoho.controlpanel.reports.ReportsItemVO"} I want to parse the objects e.g. [71512,"joe","adams"] inside the second results key. And this is my attempt to call the JSON-VBA parser: Public Sub exceljson() Dim http As Object, JSON As Object, i As Integer Set http = CreateObject

Loop through named range list

旧街凉风 提交于 2020-01-06 06:24:10
问题 I found a lot of examples but it's not working in my case and I don't know why. Very basic code: Sub Test() Dim namCur As Name For Each namCur In ActiveSheet.Names MsgBox "Name: " & namCur.Name & ", Refers To: " & namCur.RefersTo Next namCur End Sub And I have the same issue when I use Worksheets("Assumptions").Names When I watch ActiveSheet.Name , this is correct I get "Assumptions", you can see on the picture below the list of named ranges. But I never get the MsgBox and the For loop goes