将数据从每 X 列移动到 Excel 中的单列中

发布于 2024-12-09 10:06:44 字数 899 浏览 0 评论 0原文

使用修改答案解决问题

Dim i As Long, values As Range, current As Range
Set current = Range("D4") '//select 1st anchor cell
Do Until current.Value = ""
    i = i + 45
    Set values = Range(current.Offset(2, 0), current.Offset(45, 0)) '//select all in the ooc column
    values.Copy '//got block of data here
    Sheets("Sheet1").Range("A" & i).PasteSpecial
    Set current = current.Offset(0, 13) '//next page
Loop

从 Excel 电子表格的 C 列开始,我有 13 列宽的数据页。我需要将第二列和第三列中的数据传输到 SQL 数据库,因此我尝试将每页上的这两列移至彼此之上进行传输。

下面的屏幕截图是我正在使用的数据。我需要捕获 ODC CSS 服务器 RowX CabX 下的服务器名称及其相应的资产标签。如果我可以每 13 行取出 2 列并将它们堆叠起来,我就可以自己删除额外的信息。

电子表格 http://img830.imageshack.us/img830/6126/unledoks.png

我确信我不需要提及这会节省大量的时间,但我确实需要一些帮助来开始使用或使用示例宏来完成此操作。不幸的是,我没有太多 VBA 经验,但我会尽我所能获得帮助。

Problem Solved using modifications to answer

Dim i As Long, values As Range, current As Range
Set current = Range("D4") '//select 1st anchor cell
Do Until current.Value = ""
    i = i + 45
    Set values = Range(current.Offset(2, 0), current.Offset(45, 0)) '//select all in the ooc column
    values.Copy '//got block of data here
    Sheets("Sheet1").Range("A" & i).PasteSpecial
    Set current = current.Offset(0, 13) '//next page
Loop

Starting in column C of an excel spreadsheet, I have pages of data 13 columns wide. I need to transfer the data in the 2nd and 3rd columns to a SQL Database, so I'm trying to move those 2 columns on each page on top of eachother for transfer.

The Screenshot below is the data im working with. I need to capture server names under ODC CSS Servers RowX CabX along with its corresponding asset tag. If i can just take those 2 columns every 13 rows and stack them I can delete the extra information on my own.

Spreadsheet http://img830.imageshack.us/img830/6126/unledoks.png

I'm sure I don't need to mention the insane amount of time this would save but I could really use some help getting started with, or using an example macro to accomplish this. I don't have much for VBA experience unfortunately, but I will work with what help I can get.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不及他 2024-12-16 10:06:44

怎么样;

dim i As Long, values as range, current As range
set current = Range("D4") '//select 1st anchor cell
do until current.Value = ""
    i = i + 1
    set values = range(current.offset(1, 0), current.End(xlToRight)) '//select all in the ooc column 
    values.copy '//got block of data here
    sheets("someothersheet").range("A" & i * 2 - 1).pastespecial
    set current = current.offset(0, 13) '//next page
loop

What about;

dim i As Long, values as range, current As range
set current = Range("D4") '//select 1st anchor cell
do until current.Value = ""
    i = i + 1
    set values = range(current.offset(1, 0), current.End(xlToRight)) '//select all in the ooc column 
    values.copy '//got block of data here
    sheets("someothersheet").range("A" & i * 2 - 1).pastespecial
    set current = current.offset(0, 13) '//next page
loop
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文