ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   fill a cell with this.. (https://www.excelbanter.com/excel-programming/418159-fill-cell.html)

pls123

fill a cell with this..
 
hi all i have to fill cell A20 with ]Sheet1'!$B$999
where 999 is the value of cell A20.
if u can describe the right syntax, that will help me a lot !! ty


Sub A22()
Dim aWB As Workbook
Dim aWS As Worksheet
Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
End Sub


Dave Peterson

fill a cell with this..
 
You left out an equal sign.

I'd use:


aWS.Range("A22").formula _
= ]Sheet1'!$B$" & aWS.Range("A20").Value

Or maybe...

with aws.range("a22")
.numberformat = "General"
.formula = _
= ]Sheet1'!$B$" & aWS.Range("A20").Value
end with

(just in case A22 was formatted as Text.)

ps. I wouldn't use an address as the name of the macro, either.

pls123 wrote:

hi all i have to fill cell A20 with ]Sheet1'!$B$999
where 999 is the value of cell A20.
if u can describe the right syntax, that will help me a lot !! ty


Sub A22()
Dim aWB As Workbook
Dim aWS As Worksheet
Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
End Sub


--

Dave Peterson

John Bundy

fill a cell with this..
 
try this
aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"pls123" wrote:

hi all i have to fill cell A20 with ]Sheet1'!$B$999
where 999 is the value of cell A20.
if u can describe the right syntax, that will help me a lot !! ty


Sub A22()
Dim aWB As Workbook
Dim aWS As Worksheet
Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
End Sub


pls123

fill a cell with this..
 
it doesn't work.
...but the = is shure correct :)

"John Bundy" wrote:

try this
aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"pls123" wrote:

hi all i have to fill cell A20 with ]Sheet1'!$B$999
where 999 is the value of cell A20.
if u can describe the right syntax, that will help me a lot !! ty


Sub A22()
Dim aWB As Workbook
Dim aWS As Worksheet
Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
End Sub


pls123

fill a cell with this..
 
OOOO it works...
but the macro named A22 didn't work..dont'know why...
i changed the name and now its' ok !

"pls123" wrote:

it doesn't work.
..but the = is shure correct :)

"John Bundy" wrote:

try this
aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"pls123" wrote:

hi all i have to fill cell A20 with ]Sheet1'!$B$999
where 999 is the value of cell A20.
if u can describe the right syntax, that will help me a lot !! ty


Sub A22()
Dim aWB As Workbook
Dim aWS As Worksheet
Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A22") = ]Sheet1'!$B$" &
aWS.Range("A20").Value
End Sub



All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com