Copy one cell via vb

Post Reply
pmakulski
Posts: 60
Joined: Mon Jun 06, 2011 6:07 pm
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Copy one cell via vb

Post by pmakulski »

Sorry, I haven't done a search of the forum. I wouldn't even know how to compose a search argument.

I made a quick slice report that has two adjacent columns.
Column C = DBRW($B$1,$A7,"Process Description")
Column D = DBRA("ExpenseProd:}Processes",A7,"Description")

(Basically, I'm moving the values of an attribute to a cube)
I want to copy the values in column D to column C

If I do a single cell manually (copy D, paste as values into C) it works. The value goes into my cube.
I tried recording this as a key stroke macro, but it just replaces the formula in column C, and it doesn't go into my cube.

Here are my two failed attempts:

Attempt 1
Dim MyCell As Range
Set MyCell = ActiveCell
MyCell.Select
Selection.Copy
MyCell.Offset(0, -1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
MyCell.Offset(1, 0).Select

Attempt 2
Dim MyCell As Range, MyString As String
Set MyCell = ActiveCell
MyString = MyCell.Value
MyCell.Offset(0, -1).Value = MyString
MyCell.Offset(1, 0).Select
lotsaram
MVP
Posts: 3702
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Copy one cell via vb

Post by lotsaram »

Why don't you just use DBSA, DBSW or DBSW formulas in Excel? No need for VBA at all really. Why reach for the sledgehammer when you already have a hammer and its all you need?

----
Edit corrected the damned spell checker that corrected VBA to "GB a" but I see you understood anyway!
Last edited by lotsaram on Thu Jan 03, 2013 8:32 pm, edited 1 time in total.
pmakulski
Posts: 60
Joined: Mon Jun 06, 2011 6:07 pm
OLAP Product: TM1
Version: 9.5.2
Excel Version: 2010

Re: Copy one cell via vb

Post by pmakulski »

Well how cool is that!
I've never used the DBSS function before.
I must have seen it since I've read the reference guide cover to cover umpteen times, but I never realized that that is what it was used for.

So I've tried it, it works.
Per my example in column E I put:
=DBSS( D7, $B$1,$A7 , "Process Description" )
then copied this formula to the lines that needed it.

Hurrah!
Thanks for your help.
Post Reply