Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2664|回复: 5

[已解决]新人请教=》单元格赋值问题!

[复制链接]
发表于 2012-8-15 17:59 | 显示全部楼层 |阅读模式
10学分
如题:将窗体中的文字框中的值,赋值给指定的单元格!(这个代码我已经写好了)
要求:单击一次《数据导入表格》后自动自动切入下一行,进行循环的数据输入!
附件视频演示下载(请下载完3个分卷,再解压):
操作视频演示.part1.rar (487.3 KB, 下载次数: 10)

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-8-15 21:46 | 显示全部楼层
回复

使用道具 举报

发表于 2012-8-15 22:02 | 显示全部楼层
本帖最后由 5201314 于 2012-8-15 22:46 编辑
  1. Private Sub CommandButton8_Click()
  2.     Dim i, LastRow
  3.     LastRow = Range("B6").End(xlDown).Row+1
  4.     For i = 1 To 7
  5.         If 卷带查询.Controls("Checkbox" & i).Value = True Then  '如果复选框(1到4)的值为真时,则运行如下代码
  6.             Cells(LastRow, 2) = 品名.Text  '赋值给=》品名
  7.             Cells(LastRow, 3) = TextBox1.Text  '赋值给=》底带规格
  8.             Cells(LastRow, 4) = TextBox3.Text  '赋值给=》底带单价
  9.             Cells(LastRow, 6) = 样式.Text  '赋值给=》胶盘样式
  10.             Cells(LastRow, 9) = TextBox11.Text  '赋值给=》异常数量
  11.             Cells(LastRow, 10) = TextBox12.Text  '赋值给=》返工数量
  12.             Cells(LastRow, 11) = TextBox13.Text  '赋值给=》异常原因
复制代码
用变量表示
LastRow = Range("B6").End(xlDown).Row+1
  Cells(LastRow
余下的自己解决,你懂的......
回复

使用道具 举报

发表于 2012-8-15 22:29 | 显示全部楼层    本楼为最佳答案   
Private Sub CommandButton8_Click()
    Dim myrow As Long, x As Integer
      myrow = Cells(29, 2).End(xlUp).Row + 1
      If Me.CheckBox1.Value = True Then Cells(myrow, 2) = 品名.Text '赋值给=》品名
      If Me.CheckBox2.Value = True Then Cells(myrow, 3) = TextBox1.Text  '赋值给=》底带规格
      If Me.CheckBox3.Value = True Then Cells(myrow, 4) = TextBox3.Text  '赋值给=》底带单价
      If Me.CheckBox4.Value = True Then Cells(myrow, 6) = 样式.Text  '赋值给=》胶盘样式
      If Me.CheckBox5.Value = True Then Cells(myrow, 9) = TextBox11.Text  '赋值给=》异常数量
      If Me.CheckBox6.Value = True Then Cells(myrow, 10) = TextBox12.Text  '赋值给=》返工数量
      If Me.CheckBox7.Value = True Then Cells(myrow, 11) = TextBox13.Text  '赋值给=》异常原因
    If OptionButton1.Value = True Then Cells(myrow, 5) = TextBox4.Text  '选项按钮1的值为真时,将文本框4的值,赋值给=》底带长度
    If OptionButton2.Value = True Then Cells(myrow, 5) = TextBox5.Text  '选项按钮2的值为真时,将文本框5的值,赋值给=》底带长度
    If OptionButton3.Value = True Then Cells(myrow, 5) = TextBox6.Text  '选项按钮3的值为真时,将文本框6的值,赋值给=》底带长度
    If OptionButton4.Value = True Then Cells(myrow, 5) = TextBox7.Text  '选项按钮4的值为真时,将文本框7的值,赋值给=》底带长度
    If OptionButton5.Value = True Then Cells(myrow, 5) = TextBox8.Text  '选项按钮5的值为真时,将文本框8的值,赋值给=》底带长度
    If OptionButton6.Value = True Then Cells(myrow, 5) = TextBox9.Text  '选项按钮6的值为真时,将文本框9的值,赋值给=》底带长度
    If OptionButton7.Value = True Then Cells(myrow, 5) = TextBox10.Text '选项按钮7的值为真时,将文本框10的值,赋值给=》底带长度
   
End Sub
回复

使用道具 举报

发表于 2012-8-16 17:49 | 显示全部楼层
兰色幻想 发表于 2012-8-15 22:29
Private Sub CommandButton8_Click()
    Dim myrow As Long, x As Integer
      myrow = Cells(29, 2). ...

兰版你好,想请你帮忙看一下,谢谢,http://www.excelpx.com/thread-256941-1-1.html
回复

使用道具 举报

发表于 2013-3-29 20:46 | 显示全部楼层
5201314 发表于 2012-8-15 22:02
用变量表示
LastRow = Range("B6").End(xlDown).Row+1
  Cells(LastRow

【求助】:
我想在单元格A35下面添加12行空白行,并且在添加的空白行A列的A36开始依次填上“2013年1月”、“2013年2月”。。。。。一直到“2013年12月”。
请问这个问题怎么用VBA代码实现呀,谢谢各位了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-10 11:03 , Processed in 0.279261 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表