# Referencing data from another sheet

#### Janet_B

##### Board Regular
Hi,

I have data on a sheet like this:
Book2.xls
KLMN
470
480
49101
5061
5181
5211
5331
54171
55131
56121
57181
580
590
600
For O-C Eq

I use a date range (which can vary) in column L:L to indicate if to use the data or not in column K:K. The data is always together ie: no blank cells between the data in K:K.

On another sheet I would like the values in K:K to start from A1 down. For example in the above, A1 would be 10, A2 would be 6 etc etc

Thanks Janet.

### Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hello Janet,
I've got a couple of questions regarding your post.
(1) Are you looking for a VBA solution or a formula/sheet function?
(2) Are all the 1 values in column L going to be consecutive, or will there be zeros and 1s within the same date?
(3) What are your sheet names?

You say "date range" in column L. Is that a typo or do you actually have dates in column L not 1s as shown in your example?

Presumably, in your example, A1 would be 10, A2 6 etc. then presumably that would go down to A9 with 18 then should A10 downward be blank?

Hi and thanks HalfAce,

(1) Are you looking for a VBA solution or a formula/sheet function?

I'd prefer a formula/sheet function but VBA would be fine too!

(2) Are all the 1 values in column L going to be consecutive, or will there be zeros and 1s within the same date?

Consecutive only.

(3) What are your sheet names?

Sheet 1 and sheet 2

Thanks again.

Cheers Janet

barry houdini said:
You say "date range" in column L. Is that a typo or do you actually have dates in column L not 1s as shown in your example?

Sorry yes it was a bit vague!

The 1's in column L reference 2 popup calendars (date range). The 1's indicate which values in column K are in the date range.

Presumably, in your example, A1 would be 10, A2 6 etc. then presumably that would go down to A9 with 18 then should A10 downward be blank?

Yes.

Cheers Janet[/quote]

Done loads of searching on this and I'm not really sure the best way to go with this. I found some code that removes blank cells but it removed everything!

Cheers Janet

Good morning Janet,
You should be able to use the AutoFilter function, perhaps like this. (Will run from any sheet.)
Code:
``````Sub Demo()
Application.ScreenUpdating = False
With Sheets("Sheet1")
.Columns("K:L").AutoFilter Field:=2, Criteria1:="1"
.Columns("K").SpecialCells(xlCellTypeVisible).Copy Sheets("Sheet2").[A1]
End With
Sheets("Sheet1").AutoFilterMode = False
Application.ScreenUpdating = True
End Sub``````
Hope it helps.
Dan

Replies
3
Views
253
Replies
6
Views
210
Replies
5
Views
503
Replies
3
Views
128
Replies
10
Views
609

1,206,945
Messages
6,075,786
Members
446,156
Latest member
Aaro23

### 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.

### Which adblocker are you using?

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

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