Excel精英培训网

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

[已解决][求组]这句话应该怎么写?

[复制链接]
发表于 2010-2-21 12:32 | 显示全部楼层 |阅读模式

If Trim(Sheets("查询").Cells(6, 2 : 6, 20).Value) = ""  Then  
     MsgBox "没有一个号码?", vbOKOnly
        Exit Sub
        End If

红色的意思想检查B6到Q6是否为空    这句话应该怎么写?

最佳答案
2010-2-21 12:46
Sub aa()
If Application.WorksheetFunction.CountA(Sheets("查询").Range("b6:U6")) = 0 Then
     MsgBox "没有一个号码?", vbOKOnly
End If
End Sub
发表于 2010-2-21 12:41 | 显示全部楼层

flag=0

y=2

do while y<21

if Trim(Sheets("查询").Cells(6,y)<>"" then flag=1

y=y+1

loop

if flag=0 then

   MsgBox "没有一个号码?", vbOKOnly
   Exit Sub
End If

回复

使用道具 举报

发表于 2010-2-21 12:46 | 显示全部楼层    本楼为最佳答案   

Sub aa()
If Application.WorksheetFunction.CountA(Sheets("查询").Range("b6:U6")) = 0 Then
     MsgBox "没有一个号码?", vbOKOnly
End If
End Sub
回复

使用道具 举报

 楼主| 发表于 2010-2-21 13:20 | 显示全部楼层

Private Sub 新增_Click()
Dim j As Integer
ax = 2

If Application.WorksheetFunction.CountA(Sheets("查询").Range("b6:U6")) = 0 Then
     MsgBox "没有一个号码?", vbOKOnly
End If
If Trim(Sheets("查询").Cells(6, 2).Value) = "" Then
               MsgBox "请输入 姓名!", vbOKOnly
End If
End Sub


Do While Not (IsEmpty(Sheets("数据库").Cells(ax, 2).Value))
ax = ax + 1
Loop
    Cells(6, 1) = Cells(1, 1)
    Cells(1, 1) = Cells(6, 1) + 1
 For j = 1 To 18
Sheets("数据库").Cells(ax, j) = Sheets("查询").Cells(6, j)
Next j
Sheets("查询").Select
         Rows("6:6").Select
         Selection.Delete Shift:=xlUp
         Range("C4").Select
         End Sub

加入后出错  单个都可以运行的

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-16 14:44 , Processed in 0.229136 second(s), 4 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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