PDA

View Full Version : [SOLVED:] Macro for moving the columns



geomano
11-14-2017, 12:30 AM
Hello, I created a macro for the purpose of checking whether there are columns with specific string my spreadsheet and in case there are, the macro should copy those columns into columns I-M. The problem is that my macro copy only the first value found into the entire column. Is there any way I could make it work? Thanks.

Sub Find()
Dim rngFound As Range
With Worksheets(3).Range("h:xy")
Set rngFound = .Find(What:="Pos", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)

Columns("i").Value = rngFound.Value
Columns("j").Value = rngFound.Offset(0, 1).Value
Columns("k").Value = rngFound.Offset(0, 2).Value
Columns("l").Value = rngFound.Offset(0, 3).Value
Columns("m").Value = rngFound.Offset(0, 4).Value

End With End Sub

snb
11-14-2017, 02:02 AM
This might be helpful:

http://www.barnesandnoble.com/w/excel-vba-programming-for-dummies-john-walkenbach/1101874584