插入行 [英] insert Row

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

问题描述

我有一个带有文本框的表单,我输入值(文本框中输入的值是唯一的
)  ;

i have a form with a text box that i enter value in it ( the value enter in text box is unique

以及一个基于textbox.text的按钮开始在我的工作表中搜索 

and a button that base on textbox.text start to search in my sheet 

我想要

如果此值在我的工作表中

一行在其下方插入 并且插入一些  ;其中的数据 

a row insert below it  and insert some  data in it 

----->

----->

对于EX: 

值= 100 

如果 在第四行找到

在其下方插入一行 

并设置: 

A5 = ramin  B5 = 1989 

推荐答案

Dim rngC As Range

Dim rngC As Range

设置rngC =工作表(" SheetName")。Cells.Find(Textbox1.Text)

Set rngC = Worksheets("SheetName").Cells.Find(Textbox1.Text)

如果不是rngC则没有那么

If Not rngC Is Nothing Then

rngC(2).EntireRow.Insert

rngC(2).EntireRow.Insert

 

工作表(" SheetName")。Cells(rngC.Row +1,1).Value =" ramin"

Worksheets("SheetName").Cells(rngC.Row +1, 1).Value = "ramin"

工作表(" SheetName")。Cells(rngC.Row +1,2).Value = 1989

Worksheets("SheetName").Cells(rngC.Row +1, 2).Value = 1989

Else

Msgbox Textbox1.Text& "未找到"

Msgbox Textbox1.Text & " was not found"

结束如果


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

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