ragav_in
Board Regular
- Joined
- Feb 13, 2006
- Messages
- 89
- Office Version
- 365
- 2016
- Platform
- Windows
Dear All,
Currently I am working on multiple workbooks where I need to extract some information from the last cell in Column A. Each files are of different format. The format of Column A is that it has data, and the bottom of the column it contains a text "Count of Records: 1234". Basically this tells how many records are there in that excel workbook. I wrote a code to extract the value of '1234' from this cell to copy into another summary sheet
The above code works if the text "Record Count" is available in Column A, but in some cases due to human interference, the cell that contains the summary of records is deleted. What I am trying to do is to find how many rows of data are available in this case.
The requirement is that the Code should look for the "String" "Record Count:" and extract the number from the cell; if it does not find the "String" in Column A, it has to to count the number of rows in that file and provide that as the "reccount". May I request this forum to provide me some support and guidance on how to write the code for this If Condition
If String "Record Count" exists, it should extract the number from the cell; if the excel file does not have the String "Record Count", then it has to count the Number of Rows in that file.
Note: The reason on why I use the code of "rng.Find (What:=)" is that the cell with the value "Record Count" can lie anywhere in the Column A (non-contiguous range) and hence End(xlDown) will not work (see attached screenshot).
I am thankful to anyone who puts their time and effort to read this post and help me with suggestion.
Thanks,
ragav_in
Currently I am working on multiple workbooks where I need to extract some information from the last cell in Column A. Each files are of different format. The format of Column A is that it has data, and the bottom of the column it contains a text "Count of Records: 1234". Basically this tells how many records are there in that excel workbook. I wrote a code to extract the value of '1234' from this cell to copy into another summary sheet
VBA Code:
Dim rng as Range, reccount as Long
Set rng = ActiveSheet.Columns("A:A")
reccount = Split(rng.Find(What:="Record Count", LookIn:=xlFormulas, LookAt:=xlPart, MatchCase:=False), ":")(1)
The above code works if the text "Record Count" is available in Column A, but in some cases due to human interference, the cell that contains the summary of records is deleted. What I am trying to do is to find how many rows of data are available in this case.
The requirement is that the Code should look for the "String" "Record Count:" and extract the number from the cell; if it does not find the "String" in Column A, it has to to count the number of rows in that file and provide that as the "reccount". May I request this forum to provide me some support and guidance on how to write the code for this If Condition
If String "Record Count" exists, it should extract the number from the cell; if the excel file does not have the String "Record Count", then it has to count the Number of Rows in that file.
Note: The reason on why I use the code of "rng.Find (What:=)" is that the cell with the value "Record Count" can lie anywhere in the Column A (non-contiguous range) and hence End(xlDown) will not work (see attached screenshot).
I am thankful to anyone who puts their time and effort to read this post and help me with suggestion.
Thanks,
ragav_in