This is a very basic question but I was unable to find an answer to it using the search function.
I have a worksheet
that contains the value Total Settled Deposits
and Successful Deposits
both in column B
, but the row numbers the values are in changes depending on information that is submitted in between the values.
I would like to write VBA
code that would do this: return the range in between and including the Total Settled Deposits
cell and Successful Deposits
cell into a new worksheet
.
For example, if Total Settled Deposits
is located in cell B:12
and Successful Deposits
is in B:7
, return the values in range B7:P13
. I would like the values returned in a new worksheet titled abc
.
You don't need VBA just do this. Add new sheet named abc, in B1 add this formula:
=IF(AND(ROW()>=MATCH("Successful Deposits",Sheet1!B:B,0),ROW()<=MATCH("Total Settled Deposits",Sheet1!B:B,0)),Sheet1!B1,"")
And drag it down. it will leave all of column B blank except for the matching cells on the other sheet.
Give this a try:
Sub Zero()
Set r1 = Range("B:B").Find(what:="Successful Deposits")
Set r2 = Range("B:B").Find(what:="Total Settled Deposits")
Set r3 = Range(r1, r2)
addy = r3.Address
Worksheets.Add
ActiveSheet.Name = "abc"
r3.Copy Range(addy)
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.