谁有人向NOOB提供VBA课程?! [英] CAn anyone offer a VBA lesson to a NOOB?!

查看:57
本文介绍了谁有人向NOOB提供VBA课程?!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找Excel电子表格第1页上的一些数据并将其移至另一页,以另一种格式显示。  ;我还需要对它进行分层,以便每次运行宏时,它都不会覆盖前一行。

I'm looking to pick up some data on Sheet 1 of my Excel spreadsheet and move it to another page, to display it in another format.  I also need to layer it so that every time I run the macro, it doesn't overwrite the previous line.

我有这个(这可能非常详细)

I have this (which is probably quite verbose)

Sub StatementPost()

Sub StatementPost()

范围(" g5:g5")。选择

Range("g5:g5").Select

选择.Copy

表格("Sheet2")。选择

Sheets("Sheet2").Select

范围("H2")。选择

Range("H2").Select

Selection.PasteSpecial Paste:= xlPasteValues,Operation:= xlNone,SkipBlanks:= False,Transpose:= False

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

(X3表示第1页中的三个不同值粘贴在H2附近在表2)

(X3 for three different values within sheet one being pasted adjacent to H2 on sheet 2)

感谢您的关注。

Mac

推荐答案

Sub StatementPost()

Sub StatementPost()

Dim myRow As Long

Dim myRow As Long

  myRow = Sheets(" Sheet2")。Cells(Rows.Count," H")。End(xlUp).Row + 1

 myRow = Sheets("Sheet2").Cells(Rows.Count,"H").End(xlUp).Row + 1

表格("Sheet2")。单元格(myRow,"H")。值=工作表(" Sheet1")。范围( "G5"。值。

Sheets("Sheet2").Cells(myRow,"H").Value = Worksheets("Sheet1").Range("G5").Value

'更改"H"到目的地列和"G5"到目的地列。对于其他单元格,例如....

'Change the "H" to the destination column(s) and the "G5" to the other cells, like....

表格("Sheet2")。单元格(myRow,"I")。值=工作表("Sheet1")。范围("K3")。值

Sheets("Sheet2").Cells(myRow,"I").Value = Worksheets("Sheet1").Range("K3").Value

表格("Sheet2")。单元格(myRow,"J")。值=工作表(" Sheet1")。范围(" ; M9")。值

Sheets("Sheet2").Cells(myRow,"J").Value = Worksheets("Sheet1").Range("M9").Value

结束子


这篇关于谁有人向NOOB提供VBA课程?!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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