用VBA编程提高Excel(WPS表格)效率

不幸被抓住整理数据,6K行数据,上百列,纯手动的话估计手残了。
发现本地球还存在VBA此等神器,成功救赎。
本文只是简单演示VBA的威力,详细使用方法,请自行搜索“Excel VBA 手册”(WPS也通用)

————————————————————————

统计数据
统计数据

好,我们这里有一列5874行的数据。统计“你上过多少门课”,数据的形式是数字,单元格留白的表示没有回答。
我们想统计其中“上过1~10门课”的样品数。当然,除了VBA,你还可以用其他方法轻易把它弄出来,不过这里就先用这个简单的例子来演示VBA。

1.在“开发工具”选项卡中打开VBA编辑器(WPS免费版用户是不带VBA功能的,VBA是收费软件)
2.从表格可以看到,第2-5874行都是要处理的数据。
3.在sheet1中键入代码,如下。

Sub sub_dist()
    Dim c As Range '用于选定某一格
    Count = 0 '统计符合条件的样品数
    '对选定区域的每一格进行操作
    For Each c In Range("a2:a5875")
       If c.Value > 0 And c.Value <= 10 Then '如果当格数据满足大于0不超过10,则计数加1
       Count = Count + 1
       End If
   Next c
      Range("a5875").Value = Count '在a5875这一格显示统计数据
      
End Sub
代码
代码

4. 点击上方的运行按键,运行该函数。

运行
运行

5. 结果就如你所愿,出现在了第5875行。

结果
结果

------------------
VBA能使你从大量的枯燥工作中解脱出来,让你有更多时间做更多有意义的事。
网上可以搜索到大量VBA教程~Keep learning!

实践报告:从石家庄飞,北京<->深圳(广州) 单程含税最低370元

2017年10月14日。更新:目前机场已经不报销高铁票,改由航空公司销售空铁套票。最新实践,春秋航空 珠海->石家庄->北京。在春秋航空官网搜索(珠海->北京)的机票,则会出现空铁组合,350元含税。在航班到达石家庄后,乘坐免费摆渡车到高铁正定机场站,在高铁候机楼的售票处凭证件换取高铁票。深圳->北京,广州->北京同理。
-------------------------
石家庄正定机场空铁快线优惠原文:http://www.hebeiairport.com/aqscshow.asp?id=4485
简单地说,就是正定机场报销你从北京(或其他周边城市)到正定机场的高铁动车票。活动延期延期至2014年3月31日。

【回程:深圳->北京 https://feichashao.com/szx-sjw-chi/

摘要

只要持有石家庄起飞/抵达的航班机票,即可在石家庄机场报销从北京(及几个石家庄周边城市)到正定机场的高铁动车票。
轻轻算了一下,这次 北京->石家庄->深圳 全程花费389元。当然,从深圳到小榄的75元另算。
另外一个数字是,北京->广州 的特快硬卧中铺是441元,北京->深圳 的特快硬卧中铺449.5元。
不用多解释,这一程可以说是超值的!好,开始分享经验。

实践计划

0. 5:30 从学校出发,坐387或694到北京西站;
1. 7:10-8:28,D2001,北京西->正定机场;
2. 10:10-13:05, 9C8905, 石家庄(SJW)->深圳(SZX);

Beijing -> Zhengding Airport -> Shenzhen
Beijing -> Zhengding Airport -> Shenzhen

继续阅读“实践报告:从石家庄飞,北京< ->深圳(广州) 单程含税最低370元”

Beijing(PEK)<-->Shenzhen(SZX)/Guangzhou(CAN),via Shijiazhuang: The cheapest way to fly.

This article is for those guys who don't mind troubles. ⊙﹏⊙
So, here's a saving way to travel from Beijing to Shenzhen(or Guangzhou,Hong Kong) via Shijiazhuang Zhengding International Airport(SJW), which costs you low to ¥370 and about 8 hours for a single trip.

ITINERARY
1. Beijing West Railway Station -> Shijiazhuang Zhengding International Airport Station (by High-Speed Rail)
2. Shijiazhuang Zhengding International Airport Station -> Shijiazhuang Zhengding International Airport Terminal (by Free Shuttle Bus)
3. Fly to Shenzhen(SZX)/Guangzhou(CAN)/Hong Kong(HKG). (by Spring Airline, a low cost carrier. Or other airlines.)

Beijing -> Zhengding Airport -> Shenzhen
Beijing -> Zhengding Airport -> Shenzhen

So...actually...HOW to make it possible?
1. Buy the High-Speed Rail Ticket. You can buy it via Internet, Railway Station or Ticket agents.
a. I prefer buying ticket on the Internet. (You can buy tickets 20 days before departure, but you need a UnionPay card and the website is in Chinese.) Why not ask a local friend to help you out?
b. Maybe the most convenient way for you is to buy tickets at the Railway Station.(1~18 days before departure.) Tell the clerk your DESTINATION[Zhengding International Airport] and DEPARTURE DATE, show your PASSPORT, and pay. Tips: Buy tickets at Beijing North Station(Xizhimen) may save your time.
c. Recommend : Make sure you can get cheap air tickets before buying railway tickets.

2. Book your air ticket.
(Spring Airline is a Low Cost Carrier)
a. Click in Spring Airline Offcial Website: www.china-sss.com . You can switch it to English.
b. Search your flight. (The same as you do with other airlines)
c. Purchase it immediately if the fare is low enough. (Accept both Chinese bank card and International Credit Card.)
d. Caution: Special tickets can NOT be refund. ( except Taxes and Sub-charges )

3. Make sure your Connecting Time is more than 90 mins. (From the arrival of Railway to the departure of Flight)
OK, all the bookings you need are done.

How to... GO? Take Beijing->Shenzhen as an example.
1. I brought a railway ticket departure at 7:10. So I got to Beijing WEST station at 6:00 and had a Value Breakfast at McDonald's outside the station.(The McDonald's inside the station is a robber! Well, you know the reason.) It's recommended that you get to the railway station at least 30 min before departure.
2. The train took me to Zhengding airport station. I exited the paid area, followed the airport sign to take the shuttle bus. It took me about 10 min to the airport terminal.
3. I used the Self-service machine to check in. (Or Counter.)
4. With my Boarding Pass, I took few steps to the Airport Information Counter. Showed the stuff my Boarding Pass and High-Speed Rail Ticket, then he wiped out my High-Speed Rail fare.(Yes! He will give your money back!)
5. I passed the Security Check and did as usual.
6. Shenzhen!

How can this be such cheap?
1. You know, Spring Airline is a LCC.
2. Zhengding Airport is not busy,compared to Beijing. So Airline operation is low.
3. The airport is willing to attract passengers from nearby cities, so it wipe out your rail ticket.

-----------------------------
Writing down these might help you a lot.

1. English: Beijing West Station, 中文: 北京西站;
2. English: Zhengding Airport, 中文:正定机场;
3. English: High-Speed Rail, 中文:高铁(动车);
4. English: Ticket, 中文:票;