Excel精英培训网

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

[已解决]vba 第一课练习碰到的问题不明请求帮助

[复制链接]
发表于 2012-1-2 17:55 | 显示全部楼层 |阅读模式
我在做作业是碰到的问题不理解请老师帮我解答一下。
我的作业有几个问题不明白               
                                                               
1、        如果公司1,公司2,公司3数据有几百行,在每张表筛选后面是不是要留足够的位置                        
2、        为什么我在黄色区域加条件就会出错,是不是我没做对   
我上传附表请帮忙看看   

最佳答案
2012-1-5 10:10
我看了下,在附件内说了下我的想法,希望能对你有所帮助!

vba第一讲练习提出的问题.rar

37.01 KB, 下载次数: 35

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-1-2 18:30 | 显示全部楼层
我看了一下,数据太多的老师说了以后再解决,现在不比考虑,不需要设置清除,只要按日期格式排序,自动就会好的!
回复

使用道具 举报

发表于 2012-1-5 10:10 | 显示全部楼层    本楼为最佳答案   
我看了下,在附件内说了下我的想法,希望能对你有所帮助!

第一讲练习1.rar

36.15 KB, 下载次数: 59

回复

使用道具 举报

发表于 2012-1-5 10:11 | 显示全部楼层
我看了下,在附件内说了下我的想法,希望能对你有所帮助!
回复

使用道具 举报

发表于 2012-1-5 20:46 | 显示全部楼层
有干劲!好学习!
回复

使用道具 举报

发表于 2012-1-5 22:41 | 显示全部楼层
我做的你看了没有,怎么样
回复

使用道具 举报

 楼主| 发表于 2012-1-7 18:06 | 显示全部楼层
谢谢这两天太忙没上网,今天看到了,谢谢你的批阅,我明白了
回复

使用道具 举报

发表于 2012-1-7 18:11 | 显示全部楼层
回复下载看一下。
回复

使用道具 举报

发表于 2012-1-8 10:55 | 显示全部楼层
  1. Sub 合并3个工作表()
  2. '
  3. ' 合并
  4. '

  5. '
  6.     Sheets("公司1").Select
  7.     Application.Goto Reference:="R2:R65536"
  8.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  9.     Selection.Copy
  10.     Sheets("合并").Select
  11.     Columns("A:A").Select
  12.     Selection.SpecialCells(xlCellTypeBlanks).Select
  13.     ActiveCell.Select
  14.     ActiveSheet.Paste
  15.     Sheets("公司2").Select
  16.     Application.Goto Reference:="R2:R65536"
  17.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  18.     Application.CutCopyMode = False
  19.     Selection.Copy
  20.     Sheets("合并").Select
  21.     Columns("A:A").Select
  22.     Selection.SpecialCells(xlCellTypeBlanks).Select
  23.     ActiveCell.Select
  24.     ActiveSheet.Paste
  25.     Sheets("公司3").Select
  26.     Application.Goto Reference:="R2:R65536"
  27.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  28.     Application.CutCopyMode = False
  29.     Selection.Copy
  30.     Sheets("合并").Select
  31.     Columns("A:A").Select
  32.     Selection.SpecialCells(xlCellTypeBlanks).Select
  33.     ActiveCell.Select
  34.     ActiveSheet.Paste
  35.     Columns("B:B").Select
  36.     Application.CutCopyMode = False
  37.     ActiveWorkbook.Worksheets("合并").Sort.SortFields.Clear
  38.     ActiveWorkbook.Worksheets("合并").Sort.SortFields.Add Key:=Range("B1"), SortOn _
  39.         :=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  40.     With ActiveWorkbook.Worksheets("合并").Sort
  41.         .SetRange Range("A2:D98")
  42.         .Header = xlNo
  43.         .MatchCase = False
  44.         .Orientation = xlTopToBottom
  45.         .SortMethod = xlPinYin
  46.         .Apply
  47.     End With
  48. End Sub
复制代码
我的是用的,定位功能和相对引用功能,录制时比较繁琐,我会录制但是看不懂代码,
回复

使用道具 举报

发表于 2012-1-8 10:55 | 显示全部楼层
  1. Sub 合并3个工作表()
  2. '
  3. ' 合并
  4. '

  5. '
  6.     Sheets("公司1").Select
  7.     Application.Goto Reference:="R2:R65536"
  8.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  9.     Selection.Copy
  10.     Sheets("合并").Select
  11.     Columns("A:A").Select
  12.     Selection.SpecialCells(xlCellTypeBlanks).Select
  13.     ActiveCell.Select
  14.     ActiveSheet.Paste
  15.     Sheets("公司2").Select
  16.     Application.Goto Reference:="R2:R65536"
  17.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  18.     Application.CutCopyMode = False
  19.     Selection.Copy
  20.     Sheets("合并").Select
  21.     Columns("A:A").Select
  22.     Selection.SpecialCells(xlCellTypeBlanks).Select
  23.     ActiveCell.Select
  24.     ActiveSheet.Paste
  25.     Sheets("公司3").Select
  26.     Application.Goto Reference:="R2:R65536"
  27.     Selection.SpecialCells(xlCellTypeConstants, 23).Select
  28.     Application.CutCopyMode = False
  29.     Selection.Copy
  30.     Sheets("合并").Select
  31.     Columns("A:A").Select
  32.     Selection.SpecialCells(xlCellTypeBlanks).Select
  33.     ActiveCell.Select
  34.     ActiveSheet.Paste
  35.     Columns("B:B").Select
  36.     Application.CutCopyMode = False
  37.     ActiveWorkbook.Worksheets("合并").Sort.SortFields.Clear
  38.     ActiveWorkbook.Worksheets("合并").Sort.SortFields.Add Key:=Range("B1"), SortOn _
  39.         :=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  40.     With ActiveWorkbook.Worksheets("合并").Sort
  41.         .SetRange Range("A2:D98")
  42.         .Header = xlNo
  43.         .MatchCase = False
  44.         .Orientation = xlTopToBottom
  45.         .SortMethod = xlPinYin
  46.         .Apply
  47.     End With
  48. End Sub
复制代码
我的是用的,定位功能和相对引用功能,录制时比较繁琐,我会录制但是看不懂代码,
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-19 10:51 , Processed in 0.154698 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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