开发者

Move data from every X column into single column in Excel

开发者 https://www.devze.com 2023-04-12 15:10 出处:网络
Problem Solved using modifications to answer Dim i As Long, values As Range, current As Range Set current = Range(\"D4\") \'//select 1st anchor cell

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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消