将值和数字格式从一个范围复制到另一个范围? [英] Copy values and numberformat from one range to another?

查看:77
本文介绍了将值和数字格式从一个范围复制到另一个范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的行中没有错误,该行将值从一个范围复制到另一个范围:

I got no error with the line below where I copy the values from one range to another:

ThisWorkbook.Sheets("Output").Range("F" & lastRowOutput + 1 & ":" & "M" & lastRowOutput + 1).Value = projectWb.Sheets("Beställningar").Range("B" & row & ":" & "I" & row).Value

但是当我尝试对NumberFormat做同样的事情时,我收到一条错误消息:

But when I try to do the same with the NumberFormat I get an error message:

ThisWorkbook.Sheets("Output").Range("F" & lastRowOutput + 1 & ":" & "M" & lastRowOutput + 1).NumberFormat = projectWb.Sheets("Beställningar").Range("B" & row & ":" & "I" & row).NumberFormat

我真正想要实现的是将值从一个范围复制到另一个范围,并将文本值保留为文本,将数字值保留为数字.

What I really want to achieve is to copy values from one range to another, and retain the text values as text and number values as numbers.

推荐答案

尝试以下方法:

projectWb.Sheets("Beställningar").Range("B" & Row & ":" & "I" & Row).Copy
ThisWorkbook.Sheets("Output").Range("F" & lastRowOutput + 1).PasteSpecial xlPasteValuesAndNumberFormats

这篇关于将值和数字格式从一个范围复制到另一个范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆