使用参考Excel VBA将单行转换为单列 [英] Transform Single Row to Single Column with Reference Excel VBA

查看:170
本文介绍了使用参考Excel VBA将单行转换为单列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题: 我经常需要将一行引用到一列(使用= Cell).当我需要对多行进行操作时,只需使用Ctrl + Shift + Enter.但这很烦人,因为错误:当我想编辑某些内容时,您无法更改数组的一部分".

Problem: I often need to refer a row to a column (using =Cell). When I need to do it with multiple row, I just use Ctrl+Shift+Enter. But it is annoying because error: "you cannot change part of an array" when I would like to edit something.

说明预期结果: 我想选择的范围是没有标题的单行.

Explain expected result: I would like to choose the range which is the single row without a header.

Dim cRangeColumn As Range
Set cRangeColumn = Application.InputBox("Please choose a range", "Specify Range", Type:=8)

按确定"后,应该让我选择将行(列的转置为单行)放置在什么位置-单元格地址,以使程序知道从何处开始

After I press "OK", it should let me choose where I put my row(single row which is transposed of the column) - a cell address to let the program knows where to start

同样,这可以通过

Dim rRangeRow As Range
Set rRangeRow = Application.InputBox("Please choose a range", "Specify Range", Type:=8)

我面临的问题: 如何访问范围内的值

Problem I face: How to access the value in range

逻辑:

  1. 我得到列的范围-假设$E$29:$E$37-总9值

我选择转置列(一行)的起始地址,假设Sheet226!$G$14

I choose the start address of the transposed column (a row), let say Sheet226!$G$14

程序开始写入="$E$29 to the starting address "Sheet226!$G$14",然后写入 直到$E$37被满足.每次写入时,都会偏移1列.

Program start to write ="$E$29 to the starting address "Sheet226!$G$14", then write until $E$37 is meet. Each time it writes, offset 1 column.

推荐答案

在海洋中游泳后,我得以完成这项工作

After swimming in the ocean, I was able to make this work

我尝试使用< code>",但是看起来不太好.因此,我拍摄了代码的快照.它不长.我希望它不会打扰.

I try to use the "< code > " but it does not look well. So I take the snapshot of the code. It is not lengthy. I wish it does not bother.

这篇关于使用参考Excel VBA将单行转换为单列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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