复制一个工作簿中的列并粘贴到另一个工作簿中。创建新列

时间:2015-12-15 11:26:30

标签: excel vba excel-vba

我需要每月从不同的工作簿收集数据,然后将其传输到一个主数据工作簿中。

MyFile = Dir
Range("C2:D18").Copy
ActiveWorkbook.Close False

erow = Sheet1.Cells(3, 2).End(xlUp).Offset(0, 1).Row
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range(Cells(erow, erow), Cells(erow, erow))

上面的代码传输我的数据并正确地将它们放在那个月的C列和D列中。当我在下个月尝试传输数据时,它会替换c和D中的数据。相反,我想要新数据到进入E和F栏,以及G和H后的月份。

怎么可以这样做?

1 个答案:

答案 0 :(得分:0)

我建议您查看this answer,了解如何正确使用class pictureViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextViewDelegate { @IBOutlet weak var picture: UIImageView! override func viewDidLoad() { } @IBAction func choosePictureAction(sender: AnyObject) { let alertPictureFrom = UIAlertController(title: "De dónde sacar la foto?", message: "", preferredStyle: UIAlertControllerStyle.ActionSheet) presentViewController(alertPictureFrom, animated: true, completion: nil) alertPictureFrom.addAction(UIAlertAction(title: "Cámara", style: .Default, handler: {action in let picker = UIImagePickerController() picker.sourceType = .Camera picker.delegate = self picker.allowsEditing = true self.presentViewController(picker, animated: true, completion: nil) })) alertPictureFrom.addAction(UIAlertAction(title: "Galería", style: .Default, handler: {action in let picker = UIImagePickerController() picker.sourceType = .PhotoLibrary picker.delegate = self picker.allowsEditing = true self.presentViewController(picker, animated: true, completion: nil) })) } func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) { picture.image = image picker.dismissViewControllerAnimated(true, completion: nil) } } 来读取多个文件。我不确定您是否需要一次阅读多个文件以了解您的解释,但总是很高兴看到 clean 示例! ;)

顺便说一句,请注意,Dir().Offset(0, 1)中无用,因为您最后使用erow = ...,而您的.Row仅影响单元格的列。

如果您的初始代码执行您想要的操作,这应该可以正常工作:

Offset