VBA - Excel FindNext输入框 [英] VBA - Excel FindNext Input box

查看:109
本文介绍了VBA - Excel FindNext输入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试设置find / next / replace输入框,但我不知道如何使vb这样做。目前我的代码有三个步骤。我有一个输入框,要求找到一个变量。然后,当它被找到时,它会将给定行上的所有信息放入电子表格中。如果只有一行包含所请求的信息,这将工作得很好。这是我查找函数的代码:

Hi there,

I''m trying to set up a "find / next / replace" input box, but I have no clue how to make vb do this. Currently my code has a three step process. I have an input box that asks for a variable to find. Then when it''s found, it puts it all the information on a given row into a spreadsheet. This would work just fine if there was only one row with the requested info. This is the code I have for the find function:

展开 | 选择 | Wrap | 行号

推荐答案

好的,我已经让它工作得更好了,但现在如果我正在寻找的项目不在我的搜索请求中,程序就会停止工作。这是新的缩写代码:

Okay, I''ve made it work much better, but now if the item I''m looking for is not in my search request, the program stops working. Here is the new abbreviated code:


展开 | 选择 | Wrap | 行号


它不会工作,因为循环将继续永远,直到你说'是你正在寻找的客户。


只要记住如果用户总是不回答该怎么做,或者你只是找不到名字。


好​​运
it wont work because the loop will continue forever, since is until you say that''s the client you''re looking for.

just have in mind what to do in case the user answers always no, or you just dont find the name.

Good Luck


实际上,选择否按照我想要的方式工作,它找到下一个条目并将行信息中的信息添加到表单中,然后提示用户输入是/否/取消。问是否是合适的客户。只要用户选择循环,这只会循环。


我知道我的编程并不是那么干净,但是这个程序似乎只是分解了如果我在Cells.Find命令中输入的名称(变为LookFor)不在数据列表中。


当我输入一个不存在的名称时,我收到的错误消息:对象变量或未设置块。当然,我不知道这意味着什么。我看过命令With在一些宏中,我已经完成了,但我从来没有编程一个,也不确定在Cells.Find行中是如何完成的。


我想要的是什么如果我输入一个不在speadsheet中的客户名称,该程序要告诉我,找不到客户端,请输入另一个名称。或找不到该名称的客户。然后清除表单并激活spreadseet底部的单元格(这部分已经在另一个模块中)。


感谢您的回复,我希望这更清楚地描述了我的错误我试图修复。
Actually, selecting "No" works just the way I want it to, it finds the next entry and adds the info from the row info to the form and then prompts the user with a "Yes/No/Cancel" question asking if it''s the right client. This only loops for as long as the user chooses for it to loop.

I know my programming isn''t as clean as it could be, however this program only appears to break down if the name I enter (which becomes LookFor) in the Cells.Find command isn''t in the data list.

The error message I get when I enter a name that isn''t there is: "Object variable or With block not set." Of course, I don''t know what this means. I''ve seen the command "With" in some macros I''ve done, but I''ve never had to program one and am not sure how this is done within the Cells.Find line.

What I want the program to do if I enter a client name that isn''t in the speadsheet, is to let me know that, "The client was not found, please enter another name." or "No client by that name found." And then clear the form and activate the cell at the bottom of the spreadseet (this part already in another module).

Thanks for your response, I hope this describes more clearly the bug I''m trying to fix.


这篇关于VBA - Excel FindNext输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆