• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to read data from the workbook selectively?

bncoxuk

New Member
Hi,


It's been interesting to me on how to read data selectively from the other workbook. Rather than pull all data, I just want to read values of 10 cells: the 1st cell has a unique name "ID code", and from this cell downward to the 10th cell.


Though this seems to be easy, I cannot get this work. Any one can make an example to solve this interesting one?
 
Good day bncoxuk


You probably mean more than I am reading from your question but why not just select the area of data and copy paste, if it is the same block each time just give it a name and then you can select by name even quicker!!
 
It is not ideal to copy and paste in my case. The sheet is too big and I simply want to get 10 cells of data.
 
Hi ,


Can you please tell me whether my understanding of your question is correct ?


You have a worksheet A ; you also have a workbook , let us call it B.xlsx , which has several worksheets C , D , E ,...


You now want to find some unique text string , let us call it "ID code" ( without the quotes ) anywhere in the workbook B.xlsx ; let us assume it is found in cell J133 on the tab labelled E ; you want that the cells J133 through J142 should be copied and pasted in worksheet A , in cells , let us say F57 through F66.


So , the following are specified :


1. The text string to be searched for


2. The file name of the workbook , which is to be searched


3. The number of cells which are to be copied


4. The destination address where the found cells are to be copied and pasted


Is all of the above correct ? If not , can you specify the exact details ?


Narayan
 
Hi, Narayan,


This is absolutely right. To make it slightly easy, 2. the file name of the workbook is given as Sheet1.


If you can get this work, this is really amazing to me and most Excel users.


Not sure how you will post the answer as it seems that this forum has no room to upload Excel file. But if you want to send the Excel answer to me, my email is: bncoxuk[at]gmail[dot]com
 
Hi ,


Have you tried anything which has not worked ; if so , it'll help to know what the problems were.


Googling this gives the following link , which would appear to be the right tool for this job :


http://www.cpearson.com/excel/FindAll.aspx


Did you try this ?


Narayan
 
Hi Narayan, I would not try to use VBA in my case. Only some Excel is useful to my case. Are you able to get it work?
 
Hi ,


We have had similar questions earlier , on finding a value within a range ; can you specify how large your ranges on each worksheet are likely to be ; searching an entire worksheet ( all the rows and all the columns ) using only formulae is not possible , I think.


If you can specify an approximate range of rows and columns within which the searching has to be done , I can try.


One sample file is available here :


http://speedy.sh/YdpzG/Nayak-example.xlsx


Narayan
 
Hi Narayan, the range can be set to be Sheet!A1:K100.


I'm very excited to see how this will be resolved, as I asked my friends and none of them is capable of doing it.
 
Hi ,


I am not sure that I can do it , so please don't get so excited !


In case you haven't tried it already , I suggest you post this question in the ExcelHero group forum on LinkedIn ; if it can be done , you will get an answer there.


Narayan
 
bncoxuk


At this time of night Narayan might be out enjoying or even reading for some sleep, remember the forum members have life's outside of excel :)
 
Hi, bncoxuk!


If I were you I'd give a look to these files:

https://dl.dropbox.com/u/60558749/How%20to%20read%20data%20from%20the%20workbook%20selectively_%20Source%20%28for%20bncoxuk%20at%20chandoo.org%29.xlsx

https://dl.dropbox.com/u/60558749/How%20to%20read%20data%20from%20the%20workbook%20selectively_%20Target%20%28for%20bncoxuk%20at%20chandoo.org%29.xlsm


The first one is an example source workbook with 1000x1000 cells.

The second one is the actual workbook, and it uses a little piece of VBA code as follows:

-----

[pre]
Code:
Option Explicit

Function FindAddressValue(psWorkbook As String, psWorksheet As String, _
psValue As String) As String
' constants
' declarations
Dim rng As Range, A As String
' start
' process
Set rng = Workbooks(psWorkbook).Worksheets(psWorksheet).Cells.Find( _
What:=psValue, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If rng Is Nothing Then
A = ""
Else
A = rng.Address(False, False, xlA1)
End If
' end
FindAddressValue = A
End Function
[/pre]
-----


In B1:B3 you have 3 named ranges SourceWorkbook, SourceWorksheet, SourceValue.


In B5 you have this formula to retrieve the searched value:

=FindAddressValue(SourceWorkbook;SourcetWorksheet;SourceValue)


In C5:C14, you have this formula that retrieves the required data:

=INDICE(SourceData;FILA(INDIRECTO(B$5))+FILA()-FILA(B$5);COLUMNA(INDIRECTO(B$5))) -----> in english: =INDEX(SourceData,ROW(INDIRECT(B$5))+ROW()-ROW(B$5),COLUMN(INDIRECT(B$5)))


You have an additional named range, SourceData, that points to A1:ALL1000 (1000x1000 cells) of your source workbook.


I know you preferred to not use VBA but in this way it's very simple to achieve your goal. If you don't feel comfortable with it, I'm afraid you'll have to wait for other non-VBA solutions.


Regards!
 
Hi, SirJB7, I'm really grateful and feeling impressed with your solution. I've kept it to myself and learn from it.


Thanks so much.


Of course, if some members here can provide a simple non-VBA solution, that will be helpful as well.
 
Hi, bncoxuk!

Glad you solved it. Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.

Regards!

PS: I'll keep an eye on this... just in case... every day is good to learn anything new. I couldn't find out an elegant way to achieve your goal by formulas only so I used a little of VBA.
 
Back
Top