Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
12
返回列表 发新帖
楼主: ma51267

求高手帮忙一下,如果我要将一行的数据提取到另一个模板,应该怎么做,急,在线等,谢

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

使用道具 举报

 楼主| 发表于 2017-8-6 23:12 | 显示全部楼层
qqyyh 发表于 2017-8-6 21:22
SHEET1数据要变动呀

是的,因为要制作不同数据的invioce,但表格格式不变

回复

使用道具 举报

 楼主| 发表于 2017-8-6 23:41 | 显示全部楼层
windyjw007 发表于 2017-8-6 20:50
大致做了下,目测还有后续需求,比如新生成的工作表如何命名等。。。

刚刚原来是这句出现调试的问题 .Cells(26, 9) = Split(ar(i, 6), Chr(10))(1),删了之后就可以用了,谢谢啊,不过还有个问题想问,就是表中的输入那里我想Description那项有多个,并且都是分开费用计算,在生成出来的invoice表中如何体现?

点评

表格要规范,多项的话请说明规则,每个都用换行符隔开吗?最多会有几个?  发表于 2017-8-7 12:53
回复

使用道具 举报

 楼主| 发表于 2017-8-10 11:59 | 显示全部楼层
windyjw007 发表于 2017-8-6 20:50
大致做了下,目测还有后续需求,比如新生成的工作表如何命名等。。。

你好,之前沒有说清楚,具体有些小更改,已发到附件中,麻烦大大帮忙看看应该如何修改~!谢谢

ABSLimited.rar

13.86 KB, 下载次数: 3

点评

能不能提供2-3组数据,并模拟下结果?1组数据目测还要返工的。。。  发表于 2017-8-10 21:41
今天太忙,回去有时间再帮你看一下  发表于 2017-8-10 16:58
回复

使用道具 举报

 楼主| 发表于 2017-8-11 11:18 | 显示全部楼层
windyjw007 发表于 2017-8-6 20:50
大致做了下,目测还有后续需求,比如新生成的工作表如何命名等。。。

我已放了2组数据作参考,由于我才刚刚接触VBA,有些还是不会填写,希望大大能帮帮忙~,谢谢~!

ABSLimited.rar

22.47 KB, 下载次数: 2

回复

使用道具 举报

发表于 2017-8-12 22:26 | 显示全部楼层
ma51267 发表于 2017-8-11 11:18
我已放了2组数据作参考,由于我才刚刚接触VBA,有些还是不会填写,希望大大能帮帮忙~,谢谢~!

将就着用吧!模板请不要改动,数据源务必放在模板后面,即:从左数到右第2个工作表,后面不要再添加任何无关的工作表了,因为代码会自动删掉之后的工作表。{:1612:}
调格式太累了,感觉数据还不够典型,就这样吧!{:2712:}
  1. Sub test()
  2.     Dim ar, br, cr, dr(1 To 100, 1 To 1), er(1 To 100, 1 To 1)
  3.     Dim i As Long, j As Long
  4.     Application.ScreenUpdating = False
  5.     Application.DisplayAlerts = False
  6.     ar = Sheets(2).Cells(1, 1).CurrentRegion
  7.         For i = Sheets.Count To 3 Step -1
  8.             Sheets(i).Delete
  9.         Next i
  10.     For i = 2 To UBound(ar)
  11.         Sheets("模板").Copy , Sheets(Sheets.Count)
  12.         With ActiveSheet
  13.             .Cells(9, 2) = ar(i, 4)
  14.             If IsEmpty(ar(i, 2)) Then
  15.                 .Cells(9, 9) = "'bsdq95" & ar(i, 1)
  16.             Else
  17.                 .Cells(9, 9) = "'bsdq95" & ar(i, 1) & "-" & ar(i, 2)
  18.             End If
  19.             .Cells(14, 3) = ar(i, 10)
  20.             .Cells(14, 9) = ar(i, 3)
  21.             If IsEmpty(ar(i, 8)) Then
  22.                 br = Split(ar(i, 5), Chr(10))
  23.                 cr = Split(ar(i, 6), Chr(10))
  24.                 For j = 0 To UBound(br)
  25.                     dr(j + 1, 1) = br(j)
  26.                     er(j + 1, 1) = cr(j)
  27.                 Next j
  28.                 .Rows("19:" & 22 + j).Insert Shift:=xlDown
  29.                 With .Cells(19, 9)
  30.                     .Value = "HKD"
  31.                     .HorizontalAlignment = xlCenter
  32.                     .Font.Underline = xlUnderlineStyleDouble
  33.                 End With
  34.                 With .Cells(20, 1).Resize(j)
  35.                     .Value = dr
  36.                     .Interior.ColorIndex = 6
  37.                 End With
  38.                 .Cells(20, 9).Resize(j) = er
  39.                 With .Cells(21 + j, 9)
  40.                     .Value = "=SUM(I20:I" & 20 + j & ")"
  41.                     .Interior.ColorIndex = 6
  42.                 End With
  43.                 .Cells(20, 9).Resize(j + 2).Style = "Comma"
  44.             Else
  45.                 .Rows("19:22").Insert Shift:=xlDown
  46.                 .Cells(21, 1) = "RE : "
  47.                 .Cells(21, 2) = ar(i, 4)
  48.                 .Cells(21, 1).Resize(, 2).Font.Bold = True
  49.                 With .Cells(22, 9)
  50.                     .Value = "USD"
  51.                     .HorizontalAlignment = xlCenter
  52.                     .Font.Underline = xlUnderlineStyleSingle
  53.                 End With
  54.                 br = Split(ar(i, 5), Chr(10))
  55.                 cr = Split(ar(i, 8), Chr(10))
  56.                 For j = 0 To UBound(br)
  57.                     dr(j + 1, 1) = br(j)
  58.                     er(j + 1, 1) = cr(j)
  59.                 Next j
  60.                 .Rows("24:" & 31 + j).Insert Shift:=xlDown
  61.                 .Cells(24, 1).Resize(j + 1) = dr
  62.                 With .Cells(24, 9)
  63.                     .Resize(j + 1) = er
  64.                     .Interior.ColorIndex = 6
  65.                 End With
  66.                 .Cells(27 + j, 7) = "Equivalent to CNY"
  67.                 .Cells(27 + j, 8) = "=I" & 27 + j & "*6.8"
  68.                 With .Cells(27 + j, 9)
  69.                     .Value = "=SUM(I24:I" & 26 + j & ")"
  70.                     .Font.Underline = xlUnderlineStyleDouble
  71.                 End With
  72.                 With .Cells(27 + j, 7).Resize(, 3)
  73.                     .Interior.ColorIndex = 6
  74.                     .Font.Bold = True
  75.                 End With
  76.                 .Cells(27 + j, 7).HorizontalAlignment = xlRight
  77.                 .Cells(28 + j, 9).Font.Underline = xlUnderlineStyleDouble
  78.                 With .Cells(29 + j, 1)
  79.                     .Value = "BY REMITTANCE :"
  80.                     .Font.Bold = True
  81.                     .Font.Underline = xlUnderlineStyleSingle
  82.                 End With
  83.                 .Cells(30 + j, 1) = "Additional bank charges CNY155.00"
  84.                 .Cells(30 + j, 7) = "Equivalent to CNY"
  85.                 .Cells(30 + j, 8) = "=H" & 27 + j & "+155"
  86.                 With .Cells(30 + j, 9)
  87.                     .Value = "=I" & 27 + j & "+20"
  88.                     .Font.Underline = xlUnderlineStyleDouble
  89.                 End With
  90.                 With .Cells(30 + j, 1).Resize(, 9)
  91.                     .Font.Bold = True
  92.                 End With
  93.                 .Cells(30 + j, 1).Interior.ColorIndex = 6
  94.                 .Cells(30 + j, 7).HorizontalAlignment = xlRight
  95.                 With .Cells(30 + j, 7).Resize(, 3)
  96.                     .Interior.ColorIndex = 6
  97.                     .Font.Bold = True
  98.                 End With
  99.                 .Cells(24, 9).Resize(j + 7).Style = "Comma"
  100.             End If
  101.             Erase dr
  102.             Erase er
  103.         End With
  104.     Next i
  105.     Application.DisplayAlerts = True
  106.     Application.ScreenUpdating = True
  107. End Sub
复制代码


ABSLimited.zip

30.57 KB, 下载次数: 2

回复

使用道具 举报

 楼主| 发表于 2017-8-13 16:53 | 显示全部楼层
windyjw007 发表于 2017-8-12 22:26
将就着用吧!模板请不要改动,数据源务必放在模板后面,即:从左数到右第2个工作表,后面不要再添加任何 ...

谢谢大大忙里帮忙做的~!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 19:59 , Processed in 0.342650 second(s), 16 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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