Help with Endless Loop: Comparing integers from another worksheet

crisshinn

New Member
Joined
Mar 4, 2011
Messages
1
I have a program which is supposed to read a textfile and check it's contents.

Sheet1, is where I upload and read the textfile.

In Sheet2, I named it "Library" where I store all my Beneficiary name and numbers. Library sheet only has 2 columns which are Column A that contains the "BeneficiaryName", while ColumnB contains "BeneficiaryNumber"

As you can see, BeneficiaryNumber acts as an IDnumber to my BeneficiaryName.

So after reading the uploaded textfile, I need to check the value of the "BeneficiaryNumber" contained in the textfile and compare its value to my existing library found in Sheet2.

Now if the BeneficiaryNumber in my textfile exists in my Library Sheet, all is good, nothing much to do but to print it in Sheet1, however, if the BeneficiaryNumber is not found in my Library, I need to have a pop-up or messageBox that will say "Error, no BeneficiaryNumber xxxxxx does not exist in Library"


However I am having an endless loop at this part of the program:

Code:
Code:
y=2

Do While Not EOF(1)
	Line Input #1, Data
	strtemp = Data

	If GetField(strtemp,1,",")="PMT" Then
		strbenenumber = GetField(strtemp,6,",")
		Sheets("Library").Select

	    Do While strbenenumber <> Sheets("Library").Range("A" & y).Value
		If strbenenumber = Sheets("Library").Range("B" & y).Value Then
			strbeneName = Sheets("Library").Range("A" & y).Value
	
		Exit Do
		End If

		y=y+1
	    Loop
	
	Sheets("Sheet1").Select
	Cells(5,3)
	If strbenenumber <> Sheets("Library").Range("B" & y).Value Then
		MsgBox ("Error! BeneficiaryNumber"&strbenenumber "does not exist!")
	End If
I'm sorry I'm not very good at debugging ;(

I'm not sure if my problem lies with my Column Range or maybe somewhere else. I've been trying to debug this for the past 4hours but I still can't get past this last problem. I'm sorry any help is really appreciated Thank you
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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