View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_7_] Bob Phillips[_7_] is offline
external usenet poster
 
Posts: 1,120
Default Populating a cell with the current value of a variable

Sub clearcontent()
Dim testvalue

testvalue = Sheets("Frequency Input").Range("J2").Value

Worksheets("Header").Range("A:G").Copy Destination:= _
Worksheets("Frequency Input").Range("J:P")

Range("J2").Value = testvalue

Application.CutCopyMode = False

End Sub


--
HTH

Bob Phillips

"Linking to specific cells in pivot table"
crosoft.com wrote in
message ...
Hi - I'm having problems populating a cell with the current value of a
variable. Basically, I'm trying to do the following:

- set the variable to the value within a specific cell
- paste over a section of a the sheet which inlcudes the cell which was

used
to set the variable value in the steop above with blank/null cells
- populate the original cell used to set the variable value with the
variable value

Below is the code I have written which is not working:

Sub clearcontent()

Dim testvalue

Sheets("Frequency Input").Select
range("J2").Select
Set testvalue = Selection

Sheets("Header").Visible = True
Sheets("Header").Select
range("A:G").Select
Selection.Copy
Sheets("Frequency Input").Select
range("J:P").Select
ActiveSheet.Paste

range("J2").Select
Selection = testvalue

Sheets("Header").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Visible = False

End Sub