PLease i need help

AbdulkareemAlhassni

New Member
Joined
Nov 16, 2018
Messages
41
Hello,

I have been having trouble with this code for more than a week, i have tried to find a solution but i could not


Code:
'THE BELOW IS MY DESIRED MAGIC
LastRow = Range("A1").End(xlDown).Row


Range("A1").Activate
n = ActiveCell.EntireRow.Find("Requisition", LookAt:=xlWhole).Column
Cells(1, n).Select
ActiveCell.Offset(1, 0).Select


'With Range(ActiveCell, ActiveCell.Offset(numRows, numCols))
With Range(ActiveCell, ActiveCell.Offset(numRows, numCols))
    .FormulaArray = "=IF(A1="""","""",A1)"
    .Replace "A1", "INDEX('PO Dist'!$W$2:'PO Dist'!$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0))"
End With


ActiveCell.AutoFill Range(ActiveCell.Address, Cells(LastRow, ActiveCell.Column))


The problem is the Code keeps only inputting A1 value in the excel sheet.

THE REPLACE DOES NOT WORK, I DONT KNOW WHY :(
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

Not fond of getting private messages saying "
hey man can you please help !"
I'm supporting the forum if and when I am able to help.
So please stop using private messages.

Now your problem: because the VBA you're showing doesn't make much sense, the principle question is:
what are you trying to achieve?
Your not giving me enough information to be able to help you.
Take a close look at the forum rules and guidance , follow them and the chance of getting support on your question is increased by numerous times.
 
Upvote 0
Code:
.Replace "A1", "INDEX('PO Dist'!$W$2:'PO Dist'!$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0))"

the first reason the Replace function did not work is that the syntax for your worksheet formula is not correct. You cannot just plug a worksheet fromula into vba in the same format as it is used on a worksheet. I don't even want to try and recode the statement. I agree with @jorismoerings that you need to give a better explanation of what you are trying to do.
 
Upvote 0
Here's some context: https://www.mrexcel.com/forum/excel-questions/1107091-vba-match-array-error-1004-a.html

Your .FormulaArray string is now <255 characters, so we don't need to use the .Replace construction.

Because you want an array formula in each cell, you need to enter the formula into a single cell and use Copy or Autofill to populate the other cells.

If instead you set the .FormulaArray property of a multi-cell range, you'll end up with a single array formula across the cells. Compare:

Code:
'Individual array formula in each cell - this is what you want
With Range("C10")   'say
    .FormulaArray = "=IF(INDEX('PO Dist'!$W$2:$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0))="""","""",INDEX('PO Dist'!$W$2:$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0)))"
    .Copy Range("C11:C15")   'or you can use autofill
End With


'One array formulae across the five cells - you don't want this!
Range("C10:C15").FormulaArray = "=IF(INDEX('PO Dist'!$W$2:$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0))="""","""",INDEX('PO Dist'!$W$2:$W$100000,MATCH(1,(A2='PO Dist'!$A$2:$A$100000)*(B2='PO Dist'!$B$2:$B$100000),0)))"
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top